ThreeDotsLabs /watermill
Building event-driven applications the easy way in Go.
★ 9,963⑂ 513👁 85⑃ 430● 263▤ 55
+3
日增长
9,963
stars
513
forks
85
watchers
430
prs
263
issues
55
releases
README
Watermill
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 PostgreSQL if that fits your use case.
Goals
Easy to understand.
Universal - event-driven architecture, messaging, stream processing, CQRS - use it for whatever you need.
Fast (see Benchmarks).
Flexible with middlewares, plugins and Pub/Sub configurations.
Resilient - using proven technologies and passing stress tests (see Stability).
Getting Started
Pick what you like the best or see in order:
1. Quickstart — learn by coding!
2. Follow the Getting Started guide.
3. See examples below.
4. Read the full documentation: https://watermill.io/
Our online hands-on training
Go Event-Driven goes beyond Watermill Quickstart. You'll learn industry standard concepts and patterns like:
Handling at-least-once delivery
Asynchronous read models
Events & Commands
Observability
Message ordering
Sagas
Examples
Basic
Your first app - start here!
Realtime feed
Router
Metrics
CQRS with protobuf
Pub/Subs usage
These examples are part of the Getting started guide and show usage of a single Pub/Sub at a time.
Real-world examples
Exactly-once delivery counter
Receiving webhooks
Sending webhooks
Synchronizing Databases
Persistent Event Log
Transactional Events
Real-time HTTP updates with Server-Sent Events
Real-time HTTP updates with Server-Sent Events and htmx
Complete projects
NATS example with live code reloading
RabbitMQ, webhooks and Kafka integration
Background
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:
go
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.
Pub/Subs
All publishers and subscribers have to implement an interface:
go
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/STop issues
#433SQLite driver14 comments · 2024-04-13#129Eventstore Pub/Sub11 comments · 2019-09-16#112Cross-languages example9 comments · 2019-08-14#5MySQL Binlog subscriber9 comments · 2018-11-18#374[watermill-kafka] - cannot process events concurrently without ACKing the event8 comments · 2023-07-26#583can watermill kafka client support sarama.NewAsyncProducer() ?6 comments · 2025-07-04#421How to subscribe to all gochannel ?6 comments · 2024-02-15#609[watermill-nats] wrongly assuming nats ackwait timeout begins when handler function is called5 comments · 2025-08-28
Discussions
#511Watermill 1.4 Released0 comments · 2024-10-29#501Welcome to Watermill Discussions!0 comments · 2024-10-10
Latest release
v1.5.3 v1.5.3 2026-08-25What's Changed Update nats docs by @m110 in https://github.com/ThreeDotsLabs/watermill/pull/694 Add setting for forwarder's handler name by @roblaszczak in https://github.com/ThreeDotsLabs/watermill/pull/695 Full Changelog: https://github.com/ThreeDotsLabs/watermill/compare/v1.5.2...v1.5.3