{"id":19969760,"url":"https://github.com/ryskiwt/pubsub-go","last_synced_at":"2025-08-14T04:26:49.422Z","repository":{"id":57603032,"uuid":"124384064","full_name":"ryskiwt/pubsub-go","owner":"ryskiwt","description":"Simple pub/sub written in Golang","archived":false,"fork":false,"pushed_at":"2018-03-09T13:29:46.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T09:11:03.931Z","etag":null,"topics":["go","golang","pubsub"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryskiwt.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-03-08T11:50:25.000Z","updated_at":"2022-09-16T09:18:17.000Z","dependencies_parsed_at":"2022-09-26T20:01:42.979Z","dependency_job_id":null,"html_url":"https://github.com/ryskiwt/pubsub-go","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/ryskiwt%2Fpubsub-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryskiwt%2Fpubsub-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryskiwt%2Fpubsub-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryskiwt%2Fpubsub-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryskiwt","download_url":"https://codeload.github.com/ryskiwt/pubsub-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241404415,"owners_count":19957655,"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":["go","golang","pubsub"],"created_at":"2024-11-13T02:51:37.504Z","updated_at":"2025-03-01T18:14:08.801Z","avatar_url":"https://github.com/ryskiwt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pubsub-go\n\nSimple pub/sub library written in Golang.\n\n[![GoDoc](https://godoc.org/github.com/ryskiwt/pubsub-go?status.svg)](https://godoc.org/github.com/ryskiwt/pubsub-go)\n[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://github.com/ryskiwt/pubsub-go/blob/master/LICENSE)\n\n### features\n- quite simple interface (Pub/Sub/PSub)\n- type of topic is string\n- type of message is interface{}\n- support pattern subscribe (PSub/PUnsub)\n\n### interface\n\n```go\ntype Hub interface {\n\tPub(topic string, msg interface{})\n\tSub(topic string) \u003c-chan interface{}\n\tUnsub(topic string, ch \u003c-chan interface{})\n\tPSub(pattern string) \u003c-chan interface{}\n\tPUnsub(pattern string, ch \u003c-chan interface{})\n\tClose()\n\tContext() context.Context\n}\n```\n\n### example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\tpubsub \"github.com/ryskiwt/pubsub-go\"\n)\n\nfunc main() {\n\n\th := pubsub.NewHub(32)\n\n\tsubChan11 := h.Sub(\"/some/topic/1\")\n\tgo func() {\n\t\tfor msg := range subChan11 {\n\t\t\tfmt.Printf(\"subChan11, TOPIC: /some/topic/1, MSG: %s\\n\", msg)\n\t\t}\n\t}()\n\tsubChan12 := h.Sub(\"/some/topic/1\")\n\tgo func() {\n\t\tfor msg := range subChan12 {\n\t\t\tfmt.Printf(\"subChan12, TOPIC: /some/topic/1, MSG: %s\\n\", msg)\n\t\t}\n\t}()\n\n\tsubChan2 := h.Sub(\"/some/topic/2\")\n\tgo func() {\n\t\tfor msg := range subChan2 {\n\t\t\tfmt.Printf(\"subChan2,  TOPIC: /some/topic/2, MSG: %s\\n\", msg)\n\t\t}\n\t}()\n\n\tsubChan3 := h.PSub(\"/some/topic/*\")\n\tgo func() {\n\t\tfor msg := range subChan3 {\n\t\t\tfmt.Printf(\"subChan3,  TOPIC: /some/topic/*, MSG: %s\\n\", msg)\n\t\t}\n\t}()\n\n\th.Pub(\"/some/topic/1\", \"message 1 !\")\n\th.Pub(\"/some/topic/2\", \"message 2 !\")\n\th.Pub(\"/some/topic/3\", \"message 3 !\")\n\th.Pub(\"/some/topic/1\", \"message 4 !\")\n\th.Pub(\"/some/topic/2\", \"message 5 !\")\n\th.Pub(\"/some/topic/3\", \"message 6 !\")\n\n\t\u003c-time.After(time.Second)\n\th.Unsub(\"/some_topic/1\", subChan11)\n\th.Unsub(\"/some_topic/1\", subChan12)\n\th.Unsub(\"/some_topic/2\", subChan2)\n\th.PUnsub(\"/some_topic/*\", subChan3)\n}\n```\n\n```sh\n$ cd example\n$ go run main.go\nsubChan11, TOPIC: /some/topic/1, MSG: message 1 !\nsubChan12, TOPIC: /some/topic/1, MSG: message 1 !\nsubChan12, TOPIC: /some/topic/1, MSG: message 4 !\nsubChan3,  TOPIC: /some/topic/*, MSG: message 1 !\nsubChan3,  TOPIC: /some/topic/*, MSG: message 2 !\nsubChan3,  TOPIC: /some/topic/*, MSG: message 4 !\nsubChan3,  TOPIC: /some/topic/*, MSG: message 5 !\nsubChan11, TOPIC: /some/topic/1, MSG: message 4 !\nsubChan2,  TOPIC: /some/topic/2, MSG: message 2 !\nsubChan2,  TOPIC: /some/topic/2, MSG: message 5 !\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryskiwt%2Fpubsub-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryskiwt%2Fpubsub-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryskiwt%2Fpubsub-go/lists"}