ThreeDotsLabs /watermill

Building event-driven applications the easy way in Go.

★ 9,963⑂ 513👁 85⑃ 430● 263▤ 55
GoMITCreated 2018-11-08watermill.io
Download: v1.5.3v1.5.3 ↓1.5.32026-08-25
+3
Daily
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/S

Top issues

Discussions

Latest release

v1.5.3 v1.5.3 2026-08-25
What'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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON