{"id":17034226,"url":"https://github.com/ar3s3ru/gobus","last_synced_at":"2025-04-12T13:12:53.353Z","repository":{"id":57506011,"uuid":"61587694","full_name":"ar3s3ru/gobus","owner":"ar3s3ru","description":"Simple library to use content-based event-driven programming with Golang","archived":false,"fork":false,"pushed_at":"2016-06-21T17:04:33.000Z","size":35,"stargazers_count":22,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T13:12:47.637Z","etag":null,"topics":["eventbus","go","golang","golang-library"],"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/ar3s3ru.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":"2016-06-20T23:37:38.000Z","updated_at":"2021-02-08T10:22:44.000Z","dependencies_parsed_at":"2022-09-26T17:51:46.406Z","dependency_job_id":null,"html_url":"https://github.com/ar3s3ru/gobus","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/ar3s3ru%2Fgobus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar3s3ru%2Fgobus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar3s3ru%2Fgobus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar3s3ru%2Fgobus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ar3s3ru","download_url":"https://codeload.github.com/ar3s3ru/gobus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571866,"owners_count":21126522,"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":["eventbus","go","golang","golang-library"],"created_at":"2024-10-14T08:42:56.570Z","updated_at":"2025-04-12T13:12:53.327Z","avatar_url":"https://github.com/ar3s3ru.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoBus [![Build Status](https://travis-ci.org/ar3s3ru/gobus.svg?branch=master)](https://travis-ci.org/ar3s3ru/gobus)\n\nSimple asynchronous, \u003cb\u003econtent-based\u003c/b\u003e event bus for Go.\n\n## Usage\n\nGoBus provides a straightforward implementation for an Event Bus.\u003c/br\u003e\nStart using the Event Bus this way:\n```go\nbus := gobus.NewEventBus()                  // Un-buffered channel\nbus := gobus.NewEventBusBuffered(chanSize)  // Buffered channel\ndefer bus.Destruct()\n```\nGoBus can use a buffered and an un-buffered channel to dispatch events as they arrive.\n\nAlways remember to call  ```bus.Destruct()``` at the end of the Event Bus usage, as it's needed for\ncleanup purposes (closing channels, returning asynchronous goroutines, ...).\n\n#### (Un)Subscription\n\nYou can subscribe (and unsubscribe) one or more listeners to the Event Bus like this:\n\n```go\nfunc useString(event string) {\n    // Do something\n}\n\nbus.Subscribe(useString)\nbus.UnSubscribe(useString)\n\n// Method chaining\nbus.Subscribe(function1).Subscribe(function2).Subscribe(function3).\n    UnSubscribe(function2).UnSubscribe(function3)\n\n// Variadic arguments\nbus.Subscribe(function1, function2, function3)\nbus.UnSubscribe(function1, function3, function2)\n\n// Having fun :-)\nbus.Subscribe(function1, function2, function3).\n    UnSubscribe(function1, function2, function3)\n```\n\nListeners must be \u003cb\u003eunary procedures\u003c/b\u003e, functions with \u003cb\u003eone input argument\u003c/b\u003e and \u003cb\u003eno return arguments.\u003c/b\u003e\n\nListeners are grouped together by their input argument types (meaning that publishing a string \u003cb\u003e\u003ci\u003ewill call every string\nlisteners registered to the bus\u003c/i\u003e\u003c/b\u003e).\n\n#### Publishing\n\nYou can publish events to the Event Bus this way:\n\n```go\nbus.Publish(\"HelloWorld!\")\n\n// Method chaining\nbus.Publish(\"HelloWorld!\").Publish(12)\n```\n\nEvents are pushed to a dispatcher channel which will asynchronously calls all the listeners registered\nto the event type.\n\n\u003cb\u003eBeing asynchronous through goroutines, there are no guarantees on the listeners calling order.\u003c/b\u003e\n\n## Contributing\n\nBiggest contribution towards this library is to use it and give us feedback for further improvements and additions.\n\nFor direct contributions, branch of from master and do _pull request_.\n\n## License\n\nThis library is distributed under the MIT License found in the\n[LICENSE](https://github.com/ar3s3ru/gobus/blob/master/LICENSE) file.\n\nWritten by Danilo Cianfrone.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Far3s3ru%2Fgobus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Far3s3ru%2Fgobus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Far3s3ru%2Fgobus/lists"}