Easy setup: Bunnify is designed to be easy to set up and use. Simply reference the library and start publishing and consuming events.
Automatic payload marshaling and unmarshaling: You can consume the same payload you published, without worrying about the details of marshaling and unmarshaling. Bunnify handles these actions for you, abstracting them away from the developer.
Automatic reconnection: If your connection to the AMQP server is interrupted, Bunnify will automatically handle the reconnection for you. This ensures that your events are published and consumed without interruption.
Built-in event metadata handling: The library automatically handles event metadata, including correlation IDs and other important details.
Minimal dependencies: The intention of the library is to avoid being a vector of attack due to lots of unneeded dependencies. I will always try to curate the dependencies and I compromise only to use:
github.com/rabbitmq/amqp091-go
: Handles the connection with AMQP protocol.github.com/google/uuid
: Generates UUID for events ID and correlation ID.go.uber.org/goleak
: Used on tests to verify that there are no leaks of routines on the handling of channels.
Every workplace I have been had their own AMQP library. Most of the time the problems that they try to solve are reconnection, logging, correlation, handling the correct body type for events and dead letter. Most of this libraries are good but also built upon some other internal libraries and with some company's specifics that makes them impossible to open source.
Some developers are often spoiled with these as they provide a good dev experience and that is great; but you cannot use it in side projects, or if you start your own company.
Bunnify aims to provide a flexible and adaptable solution that can be used in a variety of environments and scenarios. By abstracting away many of the technical details of AMQP publishing and consumption, Bunnify makes it easy to get started with event-driven architecture without needing to be an AMQP expert.
- Support for exposing Prometheus metrics.
You can find all the working examples under the tests
folder.
Both the connection and consumer structs can be configured with the typical functional options. You can find the options below:
When publishing an event, you can override the event or the correlation ID if you need. This is also achievable with options: