{"id":22283356,"url":"https://github.com/leolara/conveyor","last_synced_at":"2025-07-28T21:32:39.799Z","repository":{"id":57516698,"uuid":"189747391","full_name":"leolara/conveyor","owner":"leolara","description":"an idiomatic and asynchronous Go message broker abstraction","archived":false,"fork":false,"pushed_at":"2019-08-26T18:36:30.000Z","size":15,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-07-27T22:18:46.627Z","etag":null,"topics":["concurrency","distributed","golang","golang-package","message-broker","message-bus","message-queue"],"latest_commit_sha":null,"homepage":"","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/leolara.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":"2019-06-01T15:17:08.000Z","updated_at":"2023-03-05T04:59:42.000Z","dependencies_parsed_at":"2022-08-28T19:30:18.916Z","dependency_job_id":null,"html_url":"https://github.com/leolara/conveyor","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolara%2Fconveyor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolara%2Fconveyor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolara%2Fconveyor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolara%2Fconveyor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leolara","download_url":"https://codeload.github.com/leolara/conveyor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227959215,"owners_count":17847558,"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":["concurrency","distributed","golang","golang-package","message-broker","message-bus","message-queue"],"created_at":"2024-12-03T16:39:46.294Z","updated_at":"2024-12-03T16:39:47.075Z","avatar_url":"https://github.com/leolara.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conveyor, an idiomatic and asynchronous Go message broker abstraction\n\n[![Build Status](https://travis-ci.org/leolara/conveyor.svg?branch=master)](https://travis-ci.org/leolara/conveyor)\n[![docs](https://godoc.org/github.com/leolara/conveyor?status.svg)](http://godoc.org/github.com/leolara/conveyor)\n\nThis Go module provides an abstraction for message queues, brokers, buses and the sort. It is idiomatic and asynchronous\nbecause it uses Go channels everywhere\n\nYou can find implementations for Kafka, MQTT, NATS, NSQ, RabbitMQ, Redis, AWS SQS, STAN and STOMP at [github.com/leolara/conveyor-impl](https://github.com/leolara/conveyor-impl) \n\nThis module includes an in-memory message broker implementation that is useful for testing\n\n## How does it work\n\nWith conveyor you send and receive messages using Go channels.\n\n### Sending messages\n\nTo write to a queue called `exampleTopic` you would do:\n\n```go\n// This creates a channel to publish messages\npubChan := make(chan conveyor.SendEnvelop)\n\n// Links the publication channel to the queue or topic, from now on, what we write on pubChan will get published\n// into \"exampleTopic\"\nb.Publish(\"exampleTopic\", pubChan)\n\n// Creates a channel to receive publication errors, we can use one error channel for each publication\n// or one for all publications\npubChanErr := make(chan error)\n\n// Sends a message to \"exampleTopic\" with content []byte{24}, and with errors going pubChanErr\npubChan \u003c- conveyor.NewSendEnvelop([]byte{24}, pubChanErr)\n\n// We MUST read from pubChanErr, as it is idiomatic in Go a nil error means success.\n// We could use the same error channel for each publication or use a different time each time.\nerr := \u003c-pubChanErr\nif err != nil {\n    fmt.Errorf(\"got publication error: %s\", err)\n}\n\n// here repeat as many times as necessary writing on pubChan and reading from pubChanErr\n\n// Closing pubChan will finish the go routine in the broker that handles this publication, releasing resources\nclose(pubChan)\n\n```\n\n### Receiving messages\n\nIn the other side is as idiomatic, asynchronous and channel based as when sending messages.\n\nTo receive messages from `exampleTopic`:\n\n```go\n\n// The object sub is a subscription to \"exampleTopic\", as you can see the subscription is\n// async as it returns a channel that will eventually return the subscription object\nsub := \u003c-b.Subscribe(\"exampleTopic\")\n\n// We should check if there was an error subscribing\nif sub.Error() != nil {\n    panic(sub.Error())\n}\n\n// sub.Receive() give us a channel from which receive messages\nenvelope := \u003c-sub.Receive()\n\n// envelope.Body() returns the content of the message\nif len(envelope.Body()) != 1 \u0026\u0026 envelope.Body()[0] != 24 {\n    t.Error(\"received wrong data\")\n}\n\n// We should ack the message when we are done with it\nenvelope.Ack() \u003c- nil\n\n// after this, we can repeat reading from sub.Receive() and writing to envelope.Ack()\n\n// Once we are done, we can unsubscribe to stop receiving messages\nsub.Unsubscribe()\n\n```\n\n### Implementation specific details\n\nBoth `broker.Subscribe` and `broker.Publish` allow optional parameters that are dependent on the broker implementation.\nWriting `nil` into `envelope.Ack()` means a successful processing of the message, sending other values are implementation dependent.\n\n## Why is this different from matryer/vice\n\nThe go module vice goal is to being able to use Go channels over message brokers transparently, so the code reading and\nwriting does not have to know that there are actually a distributed messages underneath. Conveyor goal is to being able\nto use message and event brokers, buses and the sort using an idiomatic and asynchonous paradigm, which in Go means using\nchannels.\n\nIn summary they are the sides of the same coin:\n\nVice advantages: works with any code that uses `chan []byte`\n\nConveyor advantages: the user controls acknowledgments and can respond to publication errors, also access broker implementation details\n\nVice disadvantages: user cannot control acknowledgments and cannot respond to publication errors\n\nConveyor disadvantages: code that uses it needs to be aware of Conveyor interfaces\n\n## Contributing\n\nIf you have some idea for some changes, please create an issue explaining your idea before sending a pull request. We are\nhappy to have your help.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolara%2Fconveyor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleolara%2Fconveyor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolara%2Fconveyor/lists"}