{"id":43304876,"url":"https://github.com/danielhookx/eventbus","last_synced_at":"2026-02-01T20:13:43.322Z","repository":{"id":229023502,"uuid":"775458822","full_name":"danielhookx/eventbus","owner":"danielhookx","description":"Lightweight eventbus with Cross-process and async compatibility for Go.","archived":false,"fork":false,"pushed_at":"2024-04-29T08:13:35.000Z","size":3284,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T08:22:28.916Z","etag":null,"topics":["cross-process","easy-to-use","eventbus","extensible","lightweight","non-intrusive"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielhookx.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-03-21T12:35:01.000Z","updated_at":"2024-05-31T08:51:49.000Z","dependencies_parsed_at":"2024-03-21T17:28:58.759Z","dependency_job_id":"5034241c-51c3-436e-90d0-32482842c3e1","html_url":"https://github.com/danielhookx/eventbus","commit_stats":null,"previous_names":["danielhookx/eventbus"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielhookx/eventbus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielhookx%2Feventbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielhookx%2Feventbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielhookx%2Feventbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielhookx%2Feventbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielhookx","download_url":"https://codeload.github.com/danielhookx/eventbus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielhookx%2Feventbus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28988635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T18:17:03.387Z","status":"ssl_error","status_checked_at":"2026-02-01T18:16:57.287Z","response_time":56,"last_error":"SSL_read: 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":["cross-process","easy-to-use","eventbus","extensible","lightweight","non-intrusive"],"created_at":"2026-02-01T20:13:42.661Z","updated_at":"2026-02-01T20:13:43.314Z","avatar_url":"https://github.com/danielhookx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EventBus\n\nEventBus is a lightweight event bus written in Golang, which provides various enhanced features and functionalities.\n\n## Features\n\n- **Easy to use**: EventBus is a tiny library with an API that is super easy to learn. No configuration needed, you can directly create a default instance of EventBus at any position in your code.\n\n- **Cross-process**: You can enable network options during initialization to use a cross-process event bus. \n\n- **Non-intrusive**: All extensions are implemented without impacting the code of the basic functionality. You only need to enable the corresponding feature options during initialization.\n\n- **Extensible**: The code provides a unified interface for extending functionality, allowing you to customize your own advanced features.\n\n## Installation\nUse go get to install this package.\n```shell\ngo get github.com/danielhookx/xcontainer\n```\n\n## Getting Started\n### Subscribe Topic And Publish\n```go\npackage main\n\nimport (\n\t\"github.com/danielhookx/eventbus\"\n)\n\nfunc calculator(a int, b int) {\n\tfmt.Printf(\"%d\\n\", a + b)\n}\n\nfunc main() {\n    bus := eventbus.New()\n    bus.Subscribe(\"calculator\", calculator);\n    bus.Publish(\"calculator\", 10, 20);\n}\n```\n\n### Sync Subscribe Topic\n```go\nbus.SubscribeSync(\"calculator\", calculator);\n```\n\n### Unsubscribe\n```go\nbus.Unsubscribe(\"calculator\", calculator)\n```\n\n### SubscribeWith\nThere is an advanced usage of this, using the SubscribeWith method to customize the subscription behavior.\n\nIt should be noted that when using SubscribeWith, you need to ensure the uniqueness of the key yourself, and the same key will only be subscribed once.\n\n```go\npackage main\n\nimport (\n\t\"github.com/danielhookx/eventbus\"\n\t\"github.com/danielhookx/fission\"\n)\n\ntype mockDist struct {\n\tkey string\n}\n\nfunc createMockDistHandlerFunc(key any) fission.Distribution {\n\treturn \u0026mockDist{\n\t\tkey: key.(string),\n\t}\n}\n\nfunc (m *mockDist) Register(ctx context.Context) {\n\treturn\n}\nfunc (m *mockDist) Key() any {\n\treturn m.key\n}\nfunc (m *mockDist) Dist(data any) error {\n\t// add your code here\n\tfmt.Println(data)\n\treturn nil\n}\nfunc (m *mockDist) Close() error {\n\treturn nil\n}\n\nfunc main() {\n\ttopic := \"main.test\"\n    bus := eventbus.New()\n    bus.SubscribeWith(topic, \"key1\", createMockDistHandlerFunc)\n    bus.Publish(topic, \"jack\")\n\tbus.Unsubscribe(topic, \"key1\")\n}\n```\n\n### Cross Process Events\nYou only need to specify the use of netbus during initialization. Later, you can use the cross-process eventbus like the local eventbus.\n\npublisher process\n```go\npackage main\n\nimport (\n\t\"github.com/danielhookx/eventbus\"\n)\n\nfunc main() {\n\trawURL := \"tcp://:7633\"\n\tremoteURL := \"tcp://localhost:7634\"\n\n\tbus := eventbus.New(\n\t\teventbus.WithProxys(\n\t\t\teventbus.NewRPCProxyCreator(rawURL, remoteURL),\n\t\t),\n\t)\n\t\n    bus.Publish(\"test\", \"jack\")\n}\n```\n\nsubscriber process\n```go\npackage main\n\nimport (\n\t\"github.com/danielhookx/eventbus\"\n)\n\nfunc main() {\n\trawURL := \"tcp://:7634\"\n\tremoteURL := \"tcp://localhost:7633\"\n\n\tbus := eventbus.New(\n\t\teventbus.WithProxys(\n\t\t\teventbus.NewRPCProxyCreator(rawURL, remoteURL),\n\t\t),\n\t)\n\n    bus.Subscribe(\"test\", func(name string) {\n\t    fmt.Printf(\"hello %s\\n\", name)\n    })\n}\n```\n\n## Contributing\nWe welcome contributions to this project. Please submit pull requests with your proposed changes or improvements.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielhookx%2Feventbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielhookx%2Feventbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielhookx%2Feventbus/lists"}