{"id":20180797,"url":"https://github.com/frain-dev/disq","last_synced_at":"2025-10-26T08:33:55.935Z","repository":{"id":39634966,"uuid":"476253629","full_name":"frain-dev/disq","owner":"frain-dev","description":"A job-queue library providing Redis and in-memory backends.","archived":false,"fork":false,"pushed_at":"2022-05-30T11:26:33.000Z","size":85,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T05:09:24.883Z","etag":null,"topics":["job-queue","message-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/frain-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-31T10:17:21.000Z","updated_at":"2024-02-13T04:33:21.000Z","dependencies_parsed_at":"2022-09-06T12:23:08.045Z","dependency_job_id":null,"html_url":"https://github.com/frain-dev/disq","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/frain-dev/disq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frain-dev%2Fdisq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frain-dev%2Fdisq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frain-dev%2Fdisq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frain-dev%2Fdisq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frain-dev","download_url":"https://codeload.github.com/frain-dev/disq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frain-dev%2Fdisq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267624434,"owners_count":24117418,"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-07-29T02:00:12.549Z","response_time":2574,"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":["job-queue","message-queue"],"created_at":"2024-11-14T02:32:59.236Z","updated_at":"2025-10-26T08:33:50.898Z","avatar_url":"https://github.com/frain-dev.png","language":"Go","readme":"# disq\nA custom job-queue library for [convoy](https://github.com/frain-dev/convoy). Provides in-memory (localstorage) and redis (stream and list) backends only for now.\n\n# Features  \n- Redis (Stream and List), and in-memory backends.\n- Message Delay\n- Automatic retries\n\n# Usage\n\n## Create a broker\nYou can create a single broker for publishing and consuming messages from a queue. You'll need to first create a task and a message though.  \n\n```go\nimport (\n    \"github.com/frain-dev/disq\"\n    redisBroker \"github.com/frain-dev/disq/brokers/redis\"\n) \n\n//Create a Task\nvar CountHandler, _ = disq.RegisterTask(\u0026disq.TaskOptions{\n\tName: \"CountHandler\",\n\tHandler: func(name string) error {\n\t\ttime.Sleep(time.Duration(10) * time.Second)\n\t\tfmt.Println(\"Hello\", name)\n\t\treturn nil\n\t},\n\tRetryLimit: 3,\n})\n\n//Create a Message\nvar value = fmt.Sprint(\"message_\", uuid.NewString())\nvar ctx = context.Background()\n\nvar msg := \u0026disq.Message{\n    Ctx:      ctx,\n    TaskName: CountHandler.Name(),\n    Args:     []interface{}{value},\n}\n\n// Create a (redis stream) Broker\ncfg := redisBroker.RedisConfig{\n\t\tRedis:       c, //redis client\n\t\tName:        name, //name of queue\n\t\tConcurency:  int32(concurency),\n\t\tStreamGroup: \"disq:\",\n\t}\n\nvar broker = redisBroker.NewStream(\u0026cfg)\n\n// Publish and Consume with the broker\nbroker.publish(msg)\nbroker.Consume(ctx)\nbroker.Stats() //View consumer stats\n```\n\n## Create multiple brokers and assign them to a worker  \nYou can create multiple brokers, create a worker and manage those brokers with the worker. \n\n```go\nimport (\n    \"github.com/frain-dev/disq\"\n) \n//Create a worker\nvar brokers = []disq.Broker{broker1, broker2, broker3}\nvar w = disq.NewWorker(brokers)\n\n//start processing messages\nvar err = w.StartAll(ctx)\nif err != nil {\n    log.Fatal(err)\n}\n\n//Get stats from all brokers\nfor name, broker := range w.GetAllBrokers() {\n    var len, _ = broker.Len()\n    log.Printf(\"Broker_%d Queue Size: %+v\", name, len)\n    log.Printf(\"Broker_%d Stats: %+v\\n\\n\", i, broker.Stats())\n}\n```\n\n## Full example\nFor a full working example see the [example](./example/) folder. To run it; \n```bash\ngo run example/publisher/publisher.go \ngo run example/consumer/consumer.go\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Frain](https://github.com/frain-dev)\n- [taskq](https://github.com/vmihailenco/taskq)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrain-dev%2Fdisq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrain-dev%2Fdisq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrain-dev%2Fdisq/lists"}