{"id":50506269,"url":"https://github.com/pardnchiu/go-queue","last_synced_at":"2026-06-02T16:03:50.844Z","repository":{"id":329995352,"uuid":"1119356854","full_name":"pardnchiu/go-queue","owner":"pardnchiu","description":"Priority-based queue with automatic timeout promotion","archived":false,"fork":false,"pushed_at":"2026-01-01T05:55:10.000Z","size":78,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-01T08:07:13.501Z","etag":null,"topics":["backend","golang","pardnchiu","queue"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pardnchiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-19T06:32:42.000Z","updated_at":"2026-01-01T06:08:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pardnchiu/go-queue","commit_stats":null,"previous_names":["pardnchiu/go-queue"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pardnchiu/go-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pardnchiu","download_url":"https://codeload.github.com/pardnchiu/go-queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-queue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33829350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","golang","pardnchiu","queue"],"created_at":"2026-06-02T16:03:49.016Z","updated_at":"2026-06-02T16:03:50.836Z","avatar_url":"https://github.com/pardnchiu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e This README was generated by [SKILL](https://github.com/pardnchiu/skill-readme-generate), get the ZH version from [here](./README.zh.md).\n\n# go-queue\n\n[![pkg](https://pkg.go.dev/badge/github.com/pardnchiu/go-queue.svg)](https://pkg.go.dev/github.com/pardnchiu/go-queue)\n[![card](https://goreportcard.com/badge/github.com/pardnchiu/go-queue)](https://goreportcard.com/report/github.com/pardnchiu/go-queue)\n[![codecov](https://img.shields.io/codecov/c/github/pardnchiu/go-queue/master)](https://app.codecov.io/github/pardnchiu/go-queue/tree/master)\n[![license](https://img.shields.io/github/license/pardnchiu/go-queue)](LICENSE)\n[![version](https://img.shields.io/github/v/tag/pardnchiu/go-queue?label=release)](https://github.com/pardnchiu/go-queue/releases)\n\n\u003e A min-heap based priority task queue with automatic promotion, retry, and panic recovery, designed for Go concurrency workloads.\n\n## Table of Contents\n\n- [Features](#features)\n- [Architecture](#architecture)\n- [File Structure](#file-structure)\n- [License](#license)\n- [Author](#author)\n- [Stars](#stars)\n\n## Features\n\n\u003e `go get github.com/pardnchiu/go-queue` · [Documentation](./doc.md)\n\n### Five-Level Priority Scheduling with Auto-Promotion\n\nTasks are scheduled through a min-heap across five priority levels: Immediate, High, Retry, Normal, and Low. Low-priority tasks automatically promote to higher levels after exceeding a configurable wait threshold, eliminating starvation without manual intervention.\n\n### Atomic State Machine Lifecycle\n\nQueue state transitions from Created to Running to Closed are driven entirely by `atomic.CompareAndSwap`, avoiding mutexes on the Start and Shutdown paths. This ensures safe concurrent access from multiple goroutines with minimal latency.\n\n### Built-in Retry with Panic Recovery\n\nEach task supports a configurable retry limit; failed tasks re-enter the heap at Retry priority. Workers automatically recover from panics and convert them to error reports, preventing a single task crash from taking down the entire worker pool.\n\n## Architecture\n\n```mermaid\ngraph TB\n    E[Enqueue] --\u003e|Push| H[Min-Heap]\n    H --\u003e|Pop| W[Worker Pool]\n    W --\u003e|Execute| T[Task]\n    T --\u003e|Fail + Retry| H\n    H --\u003e|Promote| H\n    T --\u003e|Success| CB[Callback]\n    T --\u003e|Panic| R[Recovery → Error]\n```\n\n## File Structure\n\n```\ngo-queue/\n├── new.go              # Queue construction, worker startup and shutdown\n├── task.go             # Task struct and min-heap implementation\n├── pending.go          # Pending queue, push/pop and auto-promotion\n├── priority.go         # Priority level definitions and timeout calculation\n├── option.go           # Enqueue options (TaskID, Timeout, Callback, Retry)\n├── main_test.go        # Tests\n├── go.mod\n└── LICENSE\n```\n\n## License\n\nThis project is licensed under the [MIT LICENSE](LICENSE).\n\n## Author\n\n\u003cimg src=\"https://avatars.githubusercontent.com/u/25631760\" align=\"left\" width=\"96\" height=\"96\" style=\"margin-right: 0.5rem;\"\u003e\n\n\u003ch4 style=\"padding-top: 0\"\u003e邱敬幃 Pardn Chiu\u003c/h4\u003e\n\n\u003ca href=\"mailto:dev@pardn.io\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/email.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e \u003ca href=\"https://linkedin.com/in/pardnchiu\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/linkedin.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e\n\n## Stars\n\n[![Star](https://api.star-history.com/svg?repos=pardnchiu/go-queue\u0026type=Date)](https://www.star-history.com/#pardnchiu/go-queue\u0026Date)\n\n***\n\n©️ 2025 [邱敬幃 Pardn Chiu](https://linkedin.com/in/pardnchiu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnchiu%2Fgo-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpardnchiu%2Fgo-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnchiu%2Fgo-queue/lists"}