{"id":23873096,"url":"https://github.com/corverroos/delayq","last_synced_at":"2025-10-26T18:48:06.189Z","repository":{"id":140529681,"uuid":"416723921","full_name":"corverroos/delayq","owner":"corverroos","description":"Redis sorted-set based delay queue popping messages when their deadlines are reached.","archived":false,"fork":false,"pushed_at":"2021-10-13T12:03:15.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-22T20:14:05.048Z","etag":null,"topics":["delay-queue","go","golang","golang-library","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corverroos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-10-13T12:01:09.000Z","updated_at":"2021-10-13T12:03:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"95cc1508-c318-4441-ba5b-0deb42d3d3f1","html_url":"https://github.com/corverroos/delayq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/corverroos/delayq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corverroos%2Fdelayq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corverroos%2Fdelayq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corverroos%2Fdelayq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corverroos%2Fdelayq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corverroos","download_url":"https://codeload.github.com/corverroos/delayq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corverroos%2Fdelayq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281155559,"owners_count":26452905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"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":["delay-queue","go","golang","golang-library","redis"],"created_at":"2025-01-03T16:39:39.968Z","updated_at":"2025-10-26T18:48:06.154Z","avatar_url":"https://github.com/corverroos.png","language":"Go","readme":"# delayq\n\n`delayq` is a Go implementation of a redis based delayed queue as described \nthe [Redis In Action](https://redis.com/ebook/part-2-core-concepts/chapter-6-application-components-in-redis/6-4-task-queues/6-4-2-delayed-tasks/) ebook. \nMessages added to the queue have a deadline, the library will \"pop\" messages off the queue when the deadline is reached. \n\nIt uses a redis sorted set under the hood with messages sorted (scored) by timestamp. Messages can be added via the convenience function `delayq.Add` or\nvia `delayq.AddMsg` for more control. The blocking method `delayq.Dequeue ` pops messages as their deadlines are reached calling the callback\nfunction for each and deleting the message from the queue if the callback doesn't return an error. `delayq.Dequeue` returns on first error encountered. It\nis sufficient to call `delayq.Dequeue` in a loop, logging errors and possibly doing backoff. \n\nNotes:\n - redis sorted set scores are implemented as doubles so there is a loss of precision of popped message timestamps.\n - The combination of message ID and Data fields must be unique. `ErrExists` is returned if a message already exists. \n - The main `delayq` package is decoupled from any redis client implementation via the `delayq.Redis` interface. \n - A `radix` client implementation is provided in the `dqradix` package.\n \n## Usage\n\n```go\n// Redis client (radix)\nradixClient := radix.Dial(ctx, \"tcp\", \"localhost:6379\")\n\n// Delayq q instance\nq := delayq.New(dqradix.New(radixClient), \"z)\n\n// Add is a convenience function that adds a message to the queue with a delay; a new random UUID is generated automatically andr returned.\nuuid, err = delayq.Add(ctx, []byte(\"my message\"), time.Minute)\n\n// AddMsg adds the specified message to the queue. \nerr = delayq.AddMsg(ctx, \u0026delayq.Msg{\n    ID: uuid.New(),\n    Deadline: time.Now().Add(time.Minute),\n    Data: []byte(\"some other message\"), \n  })\n\n// Define a callback for popped messages.\ncallback := func(msg *delayq.Msg) error {\n  fmt.Printf(\"Popped message: %v\", msg)\n  return nil\n}\n\n// Run dequeue in a loop, logging errors and backing off.\nfor {\n    if ctx.Err() != nil { \n       // The root context was canceled, we are done.\n       break\n    }\n    \n    err := delayq.Dequeue(ctx, callback)\n    fmt.Printf(\"dequeue error: %v\", err)\n    time.Sleep(time.Second) // Backoff\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorverroos%2Fdelayq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorverroos%2Fdelayq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorverroos%2Fdelayq/lists"}