{"id":20695987,"url":"https://github.com/weiwenchen2022/pubsub","last_synced_at":"2025-07-04T11:05:29.038Z","repository":{"id":183648035,"uuid":"670512446","full_name":"weiwenchen2022/pubsub","owner":"weiwenchen2022","description":"Pubsub design pattern implements for Go","archived":false,"fork":false,"pushed_at":"2023-07-26T15:21:57.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T02:46:24.998Z","etag":null,"topics":["design-pattern","go","library","pubsub"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/weiwenchen2022/pubsub","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weiwenchen2022.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":"2023-07-25T08:10:09.000Z","updated_at":"2023-07-25T08:16:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e268d93-579c-4085-9022-1e2f013c9520","html_url":"https://github.com/weiwenchen2022/pubsub","commit_stats":null,"previous_names":["weiwenchen2022/pubsub"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/weiwenchen2022/pubsub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fpubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fpubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fpubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fpubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weiwenchen2022","download_url":"https://codeload.github.com/weiwenchen2022/pubsub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weiwenchen2022%2Fpubsub/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263499192,"owners_count":23476021,"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":["design-pattern","go","library","pubsub"],"created_at":"2024-11-17T00:12:10.452Z","updated_at":"2025-07-04T11:05:29.002Z","avatar_url":"https://github.com/weiwenchen2022.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pubsub\n\npackage pubsub implements the pubsub design pattern.\n\n## Install\n\n```sh\ngo get github.com/weiwenchen2022/pubsub\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/weiwenchen2022/pubsub\"\n)\n\nfunc main() {\n\tp := pubsub.NewPublisher(100*time.Millisecond, 10)\n\tdefer p.Close()\n\n\tprotobuf, _ := p.SubscribeSubject(func(subject any) bool {\n\t\ts, ok := subject.(string)\n\t\tif !ok {\n\t\t\treturn false\n\t\t}\n\t\treturn strings.Contains(s, \"protobuf\")\n\t})\n\tgrpc, _ := p.SubscribeSubject(func(subject any) bool {\n\t\ts, ok := subject.(string)\n\t\tif !ok {\n\t\t\treturn false\n\t\t}\n\t\treturn strings.Contains(s, \"grpc\")\n\t})\n\n\tgo func() {\n\t\tp.Publish(\"world\")\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\tp.Publish(\"https://grpc.io\")\n\t}()\n\n\tgo func() {\n\t\tp.Publish(\"hello\")\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\tp.Publish(\"https://protobuf.dev\")\n\t}()\n\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tgo func() {\n\t\tfmt.Println(\"protobuf subject:\", \u003c-protobuf)\n\t\twg.Done()\n\t}()\n\n\tgo func() {\n\t\tfmt.Println(\"grpc subject:\", \u003c-grpc)\n\t\twg.Done()\n\t}()\n\n\twg.Wait()\n\n\t// Unordered output:\n\t// protobuf subject: https://protobuf.dev\n\t// grpc subject: https://grpc.io\n}\n```\n\n## Reference\n\nGoDoc: [https://godoc.org/github.com/weiwenchen2022/pubsub](https://godoc.org/github.com/weiwenchen2022/pubsub)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiwenchen2022%2Fpubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweiwenchen2022%2Fpubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweiwenchen2022%2Fpubsub/lists"}