{"id":37143606,"url":"https://github.com/shift/rabbus","last_synced_at":"2026-01-14T16:52:03.406Z","repository":{"id":57555504,"uuid":"311937010","full_name":"shift/rabbus","owner":"shift","description":"A tiny wrapper over amqp exchanges and queues 🚌 ✨","archived":false,"fork":true,"pushed_at":"2020-11-11T11:05:13.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T16:47:37.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rafaeljesus/rabbus","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shift.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}},"created_at":"2020-11-11T10:29:41.000Z","updated_at":"2020-11-11T10:39:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/shift/rabbus","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/shift/rabbus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shift%2Frabbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shift%2Frabbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shift%2Frabbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shift%2Frabbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shift","download_url":"https://codeload.github.com/shift/rabbus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shift%2Frabbus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28426717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-14T16:52:02.567Z","updated_at":"2026-01-14T16:52:03.393Z","avatar_url":"https://github.com/shift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Rabbus 🚌 ✨\n\n* A tiny wrapper over [amqp](https://github.com/streadway/amqp) exchanges and queues.\n* In memory retries with exponential backoff for sending messages.\n* Protect producer calls with [circuit breaker](https://github.com/sony/gobreaker).\n* Automatic reconnect to RabbitMQ broker when connection is lost.\n* Go channel API.\n\n## Installation\n```bash\ngo get -u github.com/rafaeljesus/rabbus\n```\n\n## Usage\nThe rabbus package exposes an interface for emitting and listening RabbitMQ messages.\n\n### Emit\n```go\nimport (\n\t\"context\"\n\t\"time\"\n\n\t\"github.com/rafaeljesus/rabbus\"\n)\n\nfunc main() {\n\ttimeout := time.After(time.Second * 3)\n\tcbStateChangeFunc := func(name, from, to string) {\n\t\t// do something when state is changed\n\t}\n\tr, err := rabbus.New(\n\t\trabbusDsn,\n\t\trabbus.Durable(true),\n\t\trabbus.Attempts(5),\n\t\trabbus.Sleep(time.Second*2),\n\t\trabbus.Threshold(3),\n\t\trabbus.OnStateChange(cbStateChangeFunc),\n\t)\n\tif err != nil {\n\t\t// handle error\n\t}\n\n\tdefer func(r Rabbus) {\n\t\tif err := r.Close(); err != nil {\n\t\t\t// handle error\n\t\t}\n\t}(r)\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tgo r.Run(ctx)\n\n\tmsg := rabbus.Message{\n\t\tExchange: \"test_ex\",\n\t\tKind:     \"topic\",\n\t\tKey:      \"test_key\",\n\t\tPayload:  []byte(`foo`),\n\t}\n\n\tr.EmitAsync() \u003c- msg\n\n\tfor {\n\t\tselect {\n\t\tcase \u003c-r.EmitOk():\n\t\t\t// message was sent\n\t\tcase \u003c-r.EmitErr():\n\t\t\t// failed to send message\n\t\tcase \u003c-timeout:\n\t\t\t// handle timeout error\n\t\t}\n\t}\n}\n```\n\n### Listen\n```go\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"time\"\n\n\t\"github.com/rafaeljesus/rabbus\"\n)\n\nfunc main() {\n\ttimeout := time.After(time.Second * 3)\n\tcbStateChangeFunc := func(name, from, to string) {\n\t\t// do something when state is changed\n\t}\n\tr, err := rabbus.New(\n\t\trabbusDsn,\n\t\trabbus.Durable(true),\n\t\trabbus.Attempts(5),\n\t\trabbus.Sleep(time.Second*2),\n\t\trabbus.Threshold(3),\n\t\trabbus.OnStateChange(cbStateChangeFunc),\n\t)\n\tif err != nil {\n\t\t// handle error\n\t}\n\n\tdefer func(r Rabbus) {\n\t\tif err := r.Close(); err != nil {\n\t\t\t// handle error\n\t\t}\n\t}(r)\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tgo r.Run(ctx)\n\n\tmessages, err := r.Listen(rabbus.ListenConfig{\n\t\tExchange:    \"events_ex\",\n\t\tKind:        \"topic\",\n\t\tKey:         \"events_key\",\n\t\tQueue:       \"events_q\",\n\t\tDeclareArgs: rabbus.NewDeclareArgs().WithMessageTTL(15 * time.Minute).With(\"foo\", \"bar\"),\n\t\tBindArgs:    rabbus.NewBindArgs().With(\"baz\", \"qux\"),\n\t})\n\tif err != nil {\n\t\t// handle errors during adding listener\n\t}\n\tdefer close(messages)\n\n\tgo func(messages chan ConsumerMessage) {\n\t\tfor m := range messages {\n\t\t\tm.Ack(false)\n\t\t}\n\t}(messages)\n}\n```\n\n## Contributing\n- Fork it\n- Create your feature branch (`git checkout -b my-new-feature`)\n- Commit your changes (`git commit -am 'Add some feature'`)\n- Push to the branch (`git push origin my-new-feature`)\n- Create new Pull Request\n\n## Badges\n\n[![Build Status](https://circleci.com/gh/rafaeljesus/rabbus.svg?style=svg)](https://circleci.com/gh/rafaeljesus/rabbus)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rafaeljesus/rabbus)](https://goreportcard.com/report/github.com/rafaeljesus/rabbus)\n[![Go Doc](https://godoc.org/github.com/rafaeljesus/rabbus?status.svg)](https://godoc.org/github.com/rafaeljesus/rabbus)\n\n---\n\n\u003e GitHub [@rafaeljesus](https://github.com/rafaeljesus) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Medium [@_jesus_rafael](https://medium.com/@_jesus_rafael) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@_jesus_rafael](https://twitter.com/_jesus_rafael)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshift%2Frabbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshift%2Frabbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshift%2Frabbus/lists"}