{"id":26352045,"url":"https://github.com/spokanetech/go-meetup-worker-queue","last_synced_at":"2025-03-16T10:45:12.191Z","repository":{"id":262395957,"uuid":"887103677","full_name":"SpokaneTech/go-meetup-worker-queue","owner":"SpokaneTech","description":"A demonstration of a worker queue and worker claims roster using NATS","archived":false,"fork":false,"pushed_at":"2024-11-12T07:08:35.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T07:21:28.448Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/SpokaneTech.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":"2024-11-12T07:07:25.000Z","updated_at":"2025-03-02T22:50:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e37da60-110e-4d5b-b3d9-ad93c1419e89","html_url":"https://github.com/SpokaneTech/go-meetup-worker-queue","commit_stats":null,"previous_names":["bloveless/meetup-worker-queue","spokane-tech/meetup-worker-queue","spokane-tech/go-meetup-worker-queue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpokaneTech%2Fgo-meetup-worker-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpokaneTech%2Fgo-meetup-worker-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpokaneTech%2Fgo-meetup-worker-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpokaneTech%2Fgo-meetup-worker-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpokaneTech","download_url":"https://codeload.github.com/SpokaneTech/go-meetup-worker-queue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243857993,"owners_count":20359259,"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","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":[],"created_at":"2025-03-16T10:45:11.653Z","updated_at":"2025-03-16T10:45:12.169Z","avatar_url":"https://github.com/SpokaneTech.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# NATS Queues\n\n---\n\n## Two types of queue workers\n\n1. Standard queue with DLQ\n2. Long running work queue\n\n---\n\n## Standard queue with DLQ\n\n- Similar to SQS style work queues\n- Very simple to implement DLQ as it is just built into NATS\n- Length of work must be known and short. In this example 5 seconds, 10 seconds, and 15 seconds\n  - Although since each consumer configures it's own timeouts you can probably have some interesting patterns\n\n[Example](https://excalidraw.com/#json=VW9N6JfUwNx-lxXo2fu3a,Fwh_76wuAh1eVL14c60zxQ)\n\n---\n\n## Long running work queue\n\n- Instead of receiving work from a queue workers lobby for work\n- That work is expected to run for a very long time but might be terminated at any time\n  - if work is terminated it should be available to be reclaimed at a later date by another worker\n\n---\n\n## Long running work queue implementation\n\n- Instead of using a queue, use a key value store\n  - Redis has something available for this called a [redlock](https://redis.io/docs/latest/develop/use/patterns/distributed-locks/)/[redsync](https://github.com/go-redsync/redsync)\n  - But we can simply implement it in NATS as well\n\n- In NATS we use a separate KV bucket with a TTL\n- When a worker wants to claim some work it attempts to write a lock to the KV bucket\n- The worker updates the lock every X seconds to keep the lock owned\n- If the worker fails to update the lock it will be deleted by the TTL and available to reclaim\n\n[Example](https://excalidraw.com/#json=4ic8iBRfA7jTXOJ_8mES1,WhNaY7aejWlxNO_lMFslzQ)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspokanetech%2Fgo-meetup-worker-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspokanetech%2Fgo-meetup-worker-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspokanetech%2Fgo-meetup-worker-queue/lists"}