Watermill is a Go library for working efficiently with message streams. It is intended for building event driven applications, enabling event sourcing, RPC over messages, sagas and basically whatever else comes to your mind. You can use conventional pub/sub implementations like Kafka or RabbitMQ, but also HTTP or MySQL binlog if that fits your use case.
Documentation: https://watermill.io/
Getting started guide: https://watermill.io/docs/getting-started/
Building distributed and scalable services is rarely as easy as some may suggest. There is a lot of hidden knowledge that comes with writing such systems. Just like you don't need to know the whole TCP stack to create a HTTP REST server, you shouldn't need to study all of this knowledge to start with building message-driven applications.
Watermill's goal is to make communication with messages as easy to use as HTTP routers. It provides the tools needed to begin working with event-driven architecture and allows you to learn the details on the go.
At the heart of Watermill there is one simple interface:
func(*Message) ([]*Message, error)Your handler receives a message and decides whether to publish new message(s) or return an error. What happens next is up to the middlewares you've chosen.
You can find more about our motivations in our Introducing Watermill blog post.
- Easy to understand (see examples below).
- Universal - event-driven architecture, messaging, stream processing, CQRS - use it for whatever you need.
- Fast - (benchmarks coming soon)
- Flexible with middlewares and plugins.
- Resilient - using proven technologies and passing stress tests (results coming soon).
All publishers and subscribers have to implement an interface:
type Publisher interface {
Publish(topic string, messages ...*Message) error
Close() error
}
type Subscriber interface {
Subscribe(ctx context.Context, topic string) (<-chan *Message, error)
Close() error
}Supported Pub/Subs:
- AMQP Pub/Sub (
github.com/ThreeDotsLabs/watermill-amqp) - Google Cloud Pub/Sub (
github.com/ThreeDotsLabs/watermill-googlecloud) - HTTP Pub/Sub (
github.com/ThreeDotsLabs/watermill-http) - io.Reader/io.Writer Pub/Sub (
github.com/ThreeDotsLabs/watermill-io) - Kafka Pub/Sub (
github.com/ThreeDotsLabs/watermill-kafka) - NATS Pub/Sub (
github.com/ThreeDotsLabs/watermill-nats) - SQL Pub/Sub (
github.com/ThreeDotsLabs/watermill-sql)
All Pub/Subs implementation documentation can be found in the documentation.
- Your first app - start here!
- Simple application with publisher and subscriber
- HTTP to Kafka
- NATS example
- RabbitMQ, webhooks and Kafka integration
- ...and more!
Please check our contributing guide.
Watermill v1.0.0 has been released and is production-ready. The public API is stable and will not change without changing the major version.
To ensure that all Pub/Subs are stable and safe to use in production, we created a set of tests that need to pass for each of the implementations before merging to master. All tests are also executed in stress mode - that means that we are running all the tests 20x in parallel.
All tests are run with the race condition detector enabled (-race flag in tests).
If you didn't find the answer to your question in the documentation, feel free to ask us directly!
Please join us on the #watermill channel on the Gophers slack: You can get an invite here.
Every bit of feedback is very welcome and appreciated. Please submit it using the survey.
It processes streams!
