{"id":22945495,"url":"https://github.com/febytanzil/gobroker","last_synced_at":"2025-08-12T23:32:01.033Z","repository":{"id":35001957,"uuid":"155697357","full_name":"febytanzil/gobroker","owner":"febytanzil","description":"golang wrapper for all (to-be) kinds of message brokers","archived":false,"fork":false,"pushed_at":"2022-05-02T10:44:26.000Z","size":143,"stargazers_count":15,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-30T20:06:22.426Z","etag":null,"topics":["amqp","cloud-pubsub","go","golang","google-pubsub","messaging","nsq","nsq-client","pubsub","queue","rabbitmq"],"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/febytanzil.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":"2018-11-01T10:17:06.000Z","updated_at":"2022-12-11T11:05:18.000Z","dependencies_parsed_at":"2022-08-08T05:15:21.756Z","dependency_job_id":null,"html_url":"https://github.com/febytanzil/gobroker","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febytanzil%2Fgobroker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febytanzil%2Fgobroker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febytanzil%2Fgobroker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febytanzil%2Fgobroker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/febytanzil","download_url":"https://codeload.github.com/febytanzil/gobroker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229717177,"owners_count":18113391,"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":["amqp","cloud-pubsub","go","golang","google-pubsub","messaging","nsq","nsq-client","pubsub","queue","rabbitmq"],"created_at":"2024-12-14T14:33:13.614Z","updated_at":"2024-12-14T14:33:14.093Z","avatar_url":"https://github.com/febytanzil.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://circleci.com/gh/febytanzil/gobroker.svg?style=shield)](https://circleci.com/gh/febytanzil/gobroker)\n[![GitHub release](https://img.shields.io/github/release/febytanzil/gobroker.svg)](https://GitHub.com/febytanzil/gobroker/releases/)\n[![GitHub license](https://img.shields.io/github/license/febytanzil/gobroker.svg)](https://github.com/febytanzil/gobroker/blob/master/LICENSE)\n# gobroker\nwrapper for all (to-be) kinds of message brokers (go v1.16.x)\n\n## Supported message brokers \u0026 patterns\n### PubSub\n- RabbitMQ (*fanout*)\n- Google Cloud Pub/Sub\n- NSQ\n\n## Intentions \u0026 Features\n- Generic terms \u0026 functions to use message brokers\n- Auto reconnection\n- Limit \u0026 requeue messages*\n- Concurrent subscribers\n- Support for mockgen unit-testing\n\n## Install\n```bash\n# go get\n$ go get github.com/febytanzil/gobroker\n```\n\n## Usage\nComplete examples are provided in `examples` folder/ package\n### RabbitMQ\n```go\n// initialize publisher RabbitMQ\np := pubsub.NewPublisher(gobroker.RabbitMQ, pubsub.RabbitMQAMQP(\"amqp://guest:guest@localhost:5672/\", \"vhost\"))\n\np.Publish(\"test.fanout\", \"msg\"+t.String())\n```\n```go\n// register RabbitMQ subscriber(s) \u0026 run it\ns := pubsub.NewSubscriber(gobroker.RabbitMQ, []*pubsub.SubHandler{\n    {\n        Name:        \"test.consumer\",\n        Topic:       \"test.fanout\",\n        Handler:     testRMQ,\n        MaxRequeue:  10,\n        Concurrent:  2,\n        MaxInFlight: 3,\n    },\n}, pubsub.RabbitMQAMQP(\"amqp://guest:guest@localhost:5672/\", \"vhost\"))\n\ns.Start()\n```\n### Google\n```go\n// initialize publisher Google\np := pubsub.NewPublisher(gobroker.Google, pubsub.GoogleJSONFile(\"gcp-project-id\", \"cluster-name\", \"/path/to/google/application/credentials/cred.json\"))\n\np.Publish(\"test\", \"msg\"+t.String())\n```\n```go\n// register Google subscriber(s) \u0026 run it\ns := pubsub.NewSubscriber(gobroker.Google, []*pubsub.SubHandler{\n        {\n            Name:        \"consumer-test\",\n            Topic:       \"test-topic\",\n            Handler:     testGoogle,\n            MaxRequeue:  10,\n            Concurrent:  3,\n            Timeout:     10 * time.Minute,\n            MaxInFlight: 1,\n        },\n    },\n    pubsub.GoogleJSONFile(\"gcp-project-id\", \"cluster-name\", \"/path/to/google/application/credentials/cred.json\"))\n\t\t\ns.Start()\n```\n### Creating subcriber/ consumer\n```go\n// subcriber function format\n// return nil will ack the message as success\n// return error will requeue based on config\n\nfunc testRMQ(msg *gobroker.Message) error {\n    var encoded string\n    \n    gobroker.StdJSONCodec.Decode(msg.Body, \u0026encoded)\n    log.Println(\"consume rabbitmq:\", encoded)\n    \n    return nil\n}\nfunc testGoogle(msg *gobroker.Message) error {\n    var encoded string\n    \n    gobroker.StdJSONCodec.Decode(msg.Body, \u0026encoded)\n    log.Println(\"consume google pubsub\", encoded)\n    \n    return errors.New(\"requeue msg body: \" + encoded)\n}\n```\n\n## Notes\nDue to requeue limiter, the behavior both in RabbitMQ \u0026 Google Pub/Sub is changed to republish to the topic with additional header that contains counter to make this possible\n\n## Contributing\nPlease use a fork to create a pull request\n\n## Contributors\n- [ichsanrp](https://github.com/ichsanrp)\n- [jonathanhaposan](https://github.com/jonathanhaposan)\n- [budiryan](https://github.com/budiryan)\n- [utomorezeki](https://github.com/utomorezeki)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebytanzil%2Fgobroker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffebytanzil%2Fgobroker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebytanzil%2Fgobroker/lists"}