{"id":20852714,"url":"https://github.com/ninesstack/bunny","last_synced_at":"2025-08-09T21:03:12.559Z","repository":{"id":253253753,"uuid":"842946409","full_name":"NinesStack/bunny","owner":"NinesStack","description":"A Golang client library for RabbitMQ","archived":false,"fork":false,"pushed_at":"2024-08-15T13:04:20.000Z","size":185,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-19T06:26:42.785Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NinesStack.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}},"created_at":"2024-08-15T12:59:19.000Z","updated_at":"2024-08-15T13:04:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"98413689-0085-4c9b-a737-1b91f1a2f373","html_url":"https://github.com/NinesStack/bunny","commit_stats":null,"previous_names":["ninesstack/bunny"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NinesStack%2Fbunny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NinesStack%2Fbunny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NinesStack%2Fbunny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NinesStack%2Fbunny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NinesStack","download_url":"https://codeload.github.com/NinesStack/bunny/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243222186,"owners_count":20256229,"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":"2024-11-18T03:18:40.630Z","updated_at":"2025-03-12T13:11:43.900Z","avatar_url":"https://github.com/NinesStack.png","language":"Go","readme":"# Bunny\nA Golang client library for RabbitMQ. It wraps the [streadway/amqp](https://github.com/streadway/amqp)\nlibrary to improve ergonamics. It also provides missing functionality such as automatic reconnects, when\na connection to RabbitMQ is lost.\n\n## Usage\n\nBelow is a basic example of usage. See [examples](_examples) for more detailed usage.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/Shimmur/bunny\"\n\t\"github.com/streadway/amqp\"\n)\n\nfunc main() {\n\tb := bunny.NewRabbit(bunny.ConnectionDetails{\n\t\tURLs: []string{\"amqp://guest:guest@localhost:5672\"},\n\t})\n\n\t/*-----------\n\t| Consuming |\n\t-----------*/\n\n\t// define an exchange\n\tmyExchange := bunny.Exchange{\n\t\tName:    \"my_exchange\",\n\t\tType:    amqp.ExchangeFanout,\n\t\tDurable: true,\n\t}\n\n\t// define a queue\n\tmyQueue:= bunny.Queue{\n\t\tName:    \"my_queue\",\n\t\tDurable: true,\n\t}\n\n\t// declare a new exchange and queue, and bind the queue to the exchange\n\tc, err := b.NewConsumerChannel(\n\t\tmyExchange.Declare(),\n\t\tmyQueue.Declare(),\n\t\tmyQueue.Bind(bunny.Binding{\n\t\t\tParentExchange: \"my_exchange\",\n\t\t\tRoutingKey:     \"#\",\n\t\t}),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// function to handle each delivery on the consumer channel\n\tconsumeFunc := func(msg *amqp.Delivery) error {\n\t\t// consume logic here\n\t\treturn nil\n\t}\n\n\tif err = c.Consume(\n\t\tconsumeFunc,\n\t\tbunny.ConsumeOptions{\n\t\t\tQueueName: \"my_queue\",\n\t\t\t//optionally set qos\n\t\t\tQoSOptions: bunny.QoSOptions{\n\t\t\t\tPrefetchCount: 100,\n\t\t\t},\n        },\n\t\tnil,\n\t); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t/*------------\n\t| Publishing |\n\t------------*/\n\n\tpc, err := b.NewPublisherChannel(\n\t\tbunny.PublishOptions{},\n        bunny.Exchange{\n            Name:    \"new_exchange\",\n            Type:    amqp.ExchangeDirect,\n            Durable: true,\n        }.Declare(),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdefer func() {\n\t\tif err := pc.Close(); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}()\n\n\tmsg := amqp.Publishing{\n\t\tContentType: \"text/plan\",\n\t\tBody:        []byte(`whatever`),\n\t}\n\n\t// publish\n\tif err = pc.Publish(msg); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// publish with retries\n\tif err = pc.PublishWithRetires(msg, []time.Duration{\n\t\ttime.Millisecond * 2,\n\t}); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninesstack%2Fbunny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninesstack%2Fbunny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninesstack%2Fbunny/lists"}