Expedit
This is a golang library for interacting with message publish/subscribe brokers. It provides building blocks for creating messages producers and consumers.
Getting started
Install
go get -u github.com/quantumcycle/expedit
#then choose your implementation
go get -u github.com/quantumcycle/expedit-google-pubsub
Example
Check the code in the example folder for a working example.
Definitions
- Middleware : a function that takes a message and performs some action before and after the message being processed
- Publisher : the entrypoint for publishing messages to a broker of a pubsub implementation
- PublishingEngine : the combination of a Publisher implementation and a set of middlewares
- Subscriber : the endpoint of a pipeline receiving messages from a pubsub implementation
- Handler : a function that takes a message and performs some action with it
- Router : a component that takes care of sending a message to a message handler
- SubscriptionEngine: the combination of a Subscriber implementation, a set of middlewares and a message router
Local development
dependencies
This project uses asdf via .tool-versions to manage development dependencies. To install the dependencies after installing asdf, run asdf install.
We also rely on docker compose to install runtime/test dependencies, like the Google Pubsub emulator.pubsub
tasks
This project uses Task instead of a makefile to run project related scripts. To see the available tasks, run task -l.
Why
I created this library after trying to use Watermill in a work project. I found Watermill to be a great library,
but it's designed for more complex use cases where intricate routing is required between multiple Publishers and Subscribers. My use cases were a bit simpler,
but still, I liked some of the concepts in Watermill, like the use of middleware and the ability to integrate with multiple message brokers. So I decided
to create this library to provide a simpler interface for interacting with message brokers.
A big thanks to Three dot labs for creating Watermill and also for their Event driven Go hands-on training, which I did and greatly recommend.
License
MIT License