{"id":13424982,"url":"https://github.com/borud/broker","last_synced_at":"2025-04-23T00:18:24.892Z","repository":{"id":48890297,"uuid":"320831748","full_name":"borud/broker","owner":"borud","description":"Trivial message broker","archived":false,"fork":false,"pushed_at":"2024-10-01T11:45:27.000Z","size":49,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T00:18:17.078Z","etag":null,"topics":["broker","go","golang","golang-library","pubsub"],"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/borud.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":"2020-12-12T13:00:21.000Z","updated_at":"2024-10-01T11:43:15.000Z","dependencies_parsed_at":"2024-05-01T19:23:32.423Z","dependency_job_id":"7a86ea51-c40a-4444-b298-cff5a828b05d","html_url":"https://github.com/borud/broker","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fbroker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fbroker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fbroker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fbroker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borud","download_url":"https://codeload.github.com/borud/broker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343960,"owners_count":21415042,"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":["broker","go","golang","golang-library","pubsub"],"created_at":"2024-07-31T00:01:01.487Z","updated_at":"2025-04-23T00:18:24.871Z","avatar_url":"https://github.com/borud.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Broker - a minimal pubsub\n\n[![GoDoc Reference](https://godoc.org/github.com/borud/broker?status.svg)](http://godoc.org/github.com/borud/broker)\n\npubsub is a very small library for implementing the simplest possible\npublish-subscribe mechanism for Go using channels.\n\n## Usage\n\n    import \"github.com/borud/broker\"\n\n### Creating a new broker\n\n    broker := New(Config{\n        DownStreamChanLen:  100,\n        PublishChanLen:     100,\n        SubscribeChanLen:   10,\n        UnsubscribeChanLen: 10,\n        DeliveryTimeout:    10*time.Millisecond,\n    })\n\nThe configuration options are\n\n- `DownStreamChanLen` is the length of the channel used to send messages to the subscriber.\n\n- `PublishChanLen` is the length of the incoming channel used by `Publish()`\n\n- `SubscribeChanLen` is the length of the channel that accepts `Subscribe()` requests\n\n- `UnsubscribeChanLen` is the length of the channel that accepts unsubscribe requests.\n\n- `DeliveryTimeout` is the timeout before giving up delivering a message to a subscriber\n\n### Subscribe to topic or topic prefix\n  \n    sub, err := broker.Subscribe(\"/foo/bar\")\n\n### Fetch messages from subscription\n\n    for msg := range sub.Messages() {\n        log.Printf(\"topic = '%s', message = '%+v'\", msg.Topic, msg.Payload)\n    }\n\n### Publish message to broker with timeout\n\n    err := broker.Publish(\"/foo\", \"some payload\", 300 * time.Millisecond)\n\n### Cancel a subscription\n\n    err := sub.Cancel()\n\n### Shut down broker\n\n    broker.Shutdown()\n\n### Topics\n\nTopics are entirely dynamic, meaning that a topic exists if there are\nsubscribers listening to it.  If a message is published to a topic\nthat has no subscribers, nothing will happen and the message is\nsilently discarded.\n\nTopics are hierarchical and look like filesyste paths and matching is\nby path prefix.\n\n    /house/bedroom/light\n    /house/bedroom/temp\n    /house/kitchen/light\n    /house/kitchen/temp\n    /house/kitchen/humidity\n\nYour subscription can be for any prefix of the path, including the\nfull path.  You will receive all messages that match your prefix.  So\nfor instance if you subscribe to `/house/kitchen` you will get all\nmessages sent to\n\n    /house/kitchen\n    /house/kitchen/light\n    /house/kitchen/temp\n    /house/kitchen/humidity\n\nIf you subscribe to `/house/kitchen/temp` you will only get messages\nsent to this single topic since it has no children.\n\nAt this time **no** wildcard matching is supported.\n\n## Logging\n\nLibraries shouldn't emit log messages, but sometimes you might want to output log messages if you suspect something funny is going on.  You can register your own logger via the `Config` type, like this:\n\n    b := New(Config{Logger: log.Printf})\n\nThe `Logger` is of type `Printfer` (a Printf'er to use the naming conventions of go), which looks like this:\n\n    func(string, ...interface{})\n\n...which happens to be the signature of `log.Printf` (but not `fmt.Printf`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborud%2Fbroker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborud%2Fbroker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborud%2Fbroker/lists"}