{"id":22213954,"url":"https://github.com/xmlking/broker","last_synced_at":"2025-03-25T06:23:54.404Z","repository":{"id":43341727,"uuid":"276555327","full_name":"xmlking/broker","owner":"xmlking","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-05T20:57:42.000Z","size":104,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-01-30T05:43:17.976Z","etag":null,"topics":[],"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/xmlking.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["xmlking"],"open_collective":"xmlking"}},"created_at":"2020-07-02T05:18:26.000Z","updated_at":"2021-05-09T21:31:00.000Z","dependencies_parsed_at":"2024-06-21T02:04:25.585Z","dependency_job_id":"635f2117-1bcd-4fb2-9529-1ba931a8f8f0","html_url":"https://github.com/xmlking/broker","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"d9949db6391056508ecda1324fa830caf64e31a8"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Fbroker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Fbroker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Fbroker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlking%2Fbroker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmlking","download_url":"https://codeload.github.com/xmlking/broker/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245409529,"owners_count":20610545,"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":[],"created_at":"2024-12-02T21:12:43.307Z","updated_at":"2025-03-25T06:23:54.384Z","avatar_url":"https://github.com/xmlking.png","language":"Go","readme":"# Broker\nFramework for building async µServices \n\n## Usage\n\n### Publisher\n\n```go\npackage main\n\nimport (\n\t\"cloud.google.com/go/pubsub\"\n\t\"github.com/google/uuid\"\n\t\"github.com/rs/zerolog/log\"\n\n        \"github.com/xmlking/broker/pubsub\"\n)\n\n\nfunc main() {\n\tbroker.DefaultBroker = broker.NewBroker()\n\n\tmsg := pubsub.Message{\n\t\tID:         uuid.New().String(),\n\t\tData:       []byte(\"ABC€\"),\n\t\tAttributes: map[string]string{\"sumo\": \"demo\"},\n\t}\n\n\tif err := broker.Publish(\"my-topic\", \u0026msg); err != nil {\n\t\tlog.Error().Err(err).Send()\n\t}\n}\n```\n\n### Subscriber\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"cloud.google.com/go/pubsub\"\n\t\"github.com/rs/zerolog/log\"\n\n        \"github.com/xmlking/broker/pubsub\"\n)\n\nfunc main() {\n\tbroker.DefaultBroker = broker.NewBroker()\n\n\tmyHandler := func(ctx context.Context, msg *pubsub.Message) error {\n\n\t\tlog.Info().Interface(\"event.Message.ID\", msg.ID).Send()\n\t\tlog.Info().Interface(\"event.Message.Attributes\", msg.Attributes).Send()\n\t\tlog.Info().Interface(\"event.Message.Data\", msg.Data).Send()\n\n\t\tlog.Info().Interface(\"event.Message\", msg).Send()\n\t\tmsg.Ack() // or msg.Nack() // or return error for autoAck\n\t\treturn nil\n\t}\n\n\terr := broker.Subscribe(\"my-topic\", myHandler, broker.Queue(\"my-topic-sub\"))\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"Failed subscribing to Topic: my-topic\")\n\t}\n\n\tch := make(chan os.Signal, 1)\n\tsignal.Notify(ch, os.Interrupt)\n\t\u003c-ch\n\tlog.Info().Msg(\"Got to Go...\")\n\t// close all subs and then connection.\n\tif err := broker.Shutdown(); err != nil {\n\t\tlog.Fatal().Err(err).Msg(\"Unexpected disconnect error\")\n\t}\n}\n```\n\n\n","funding_links":["https://github.com/sponsors/xmlking","https://opencollective.com/xmlking"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlking%2Fbroker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmlking%2Fbroker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlking%2Fbroker/lists"}