{"id":13413416,"url":"https://github.com/rafaeljesus/nsq-event-bus","last_synced_at":"2025-04-27T20:32:47.373Z","repository":{"id":57483121,"uuid":"79062609","full_name":"rafaeljesus/nsq-event-bus","owner":"rafaeljesus","description":"A tiny wrapper around NSQ topic and channel :rocket:","archived":false,"fork":false,"pushed_at":"2018-02-15T22:30:14.000Z","size":56,"stargazers_count":78,"open_issues_count":2,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-07-31T20:52:19.089Z","etag":null,"topics":["event-driven","go","message-bus","microservices","nsq"],"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/rafaeljesus.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":"2017-01-15T22:05:13.000Z","updated_at":"2024-07-09T09:49:51.000Z","dependencies_parsed_at":"2022-08-27T21:02:26.076Z","dependency_job_id":null,"html_url":"https://github.com/rafaeljesus/nsq-event-bus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeljesus%2Fnsq-event-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeljesus%2Fnsq-event-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeljesus%2Fnsq-event-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeljesus%2Fnsq-event-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaeljesus","download_url":"https://codeload.github.com/rafaeljesus/nsq-event-bus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251204644,"owners_count":21552259,"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":["event-driven","go","message-bus","microservices","nsq"],"created_at":"2024-07-30T20:01:39.861Z","updated_at":"2025-04-27T20:32:47.108Z","avatar_url":"https://github.com/rafaeljesus.png","language":"Go","funding_links":[],"categories":["Go","Messaging","消息传递","消息","Relational Databases","机器学习","消息系统","\u003cspan id=\"消息-messaging\"\u003e消息 Messaging\u003c/span\u003e"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","交流","检索及分析资料库","高級控制台界面","SQL 查询语句构建库","高级控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"## Event Bus NSQ\n\n* A tiny wrapper around [go-nsq](https://github.com/nsqio/go-nsq) topic and channel.\n* Protect nsq calls with [gobreaker](https://github.com/sony/gobreaker).\n\n## Installation\n```bash\ngo get -u github.com/rafaeljesus/nsq-event-bus\n```\n\n## Usage\nThe nsq-event-bus package exposes a interface for emitting and listening events.\n\n### Emitter\n```go\nimport \"github.com/rafaeljesus/nsq-event-bus\"\n\ntopic := \"events\"\nemitter, err := bus.NewEmitter(bus.EmitterConfig{\n  Address: \"localhost:4150\",\n  MaxInFlight: 25,\n})\n\ne := event{}\nif err = emitter.Emit(topic, \u0026e); err != nil {\n  // handle failure to emit message\n}\n\n// emitting messages on a async fashion\nif err = emitter.EmitAsync(topic, \u0026e); err != nil {\n  // handle failure to emit message\n}\n\n```\n\n### Listener\n```go\nimport \"github.com/rafaeljesus/nsq-event-bus\"\n\nif err = bus.On(bus.ListenerConfig{\n  Topic:              \"topic\",\n  Channel:            \"test_on\",\n  HandlerFunc:        handler,\n  HandlerConcurrency: 4,\n}); err != nil {\n  // handle failure to listen a message\n}\n\nfunc handler(message *Message) (reply interface{}, err error) {\n  e := event{}\n  if err = message.DecodePayload(\u0026e); err != nil {\n    message.Finish()\n    return\n  }\n\n  if message.Attempts \u003e MAX_DELIVERY_ATTEMPTS {\n    message.Finish()\n    return\n  }\n\n  err, _ = doWork(\u0026e)\n  if err != nil {\n    message.Requeue(BACKOFF_TIME)\n    return\n  }\n\n  message.Finish()\n  return\n}\n```\n\n### Request (Request/Reply)\n```go\nimport \"github.com/rafaeljesus/nsq-event-bus\"\n\ntopic := \"user_signup\"\nemitter, err = bus.NewEmitter(bus.EmitterConfig{})\n\ne := event{Login: \"rafa\", Password: \"ilhabela_is_the_place\"}\nif err = bus.Request(topic, \u0026e, handler); err != nil {\n  // handle failure to listen a message\n}\n\nfunc handler(message *Message) (reply interface{}, err error) {\n  e := event{}\n  if err = message.DecodePayload(\u0026e); err != nil {\n    message.Finish()\n    return\n  }\n\n  reply = \u0026Reply{}\n  message.Finish()\n  return\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/nsq-event-bus.svg?style=svg)](https://circleci.com/gh/rafaeljesus/nsq-event-bus)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rafaeljesus/nsq-event-bus)](https://goreportcard.com/report/github.com/rafaeljesus/nsq-event-bus)\n[![Go Doc](https://godoc.org/github.com/rafaeljesus/nsq-event-bus?status.svg)](https://godoc.org/github.com/rafaeljesus/nsq-event-bus)\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%2Frafaeljesus%2Fnsq-event-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaeljesus%2Fnsq-event-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaeljesus%2Fnsq-event-bus/lists"}