Skip to content
Building event-driven applications the easy way in Go.
Go Shell Makefile
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Moved pub/subs implementations to separated repositories (#103) Jul 6, 2019
_examples fmt and add required go version go gomod (#171) Dec 18, 2019
components Add Forwarder component (#187) Jun 4, 2020
dev Update your-first-app example (#118) Aug 29, 2019
docs add og:image metadata tag in watermill.io Apr 20, 2020
internal Added missing godocs (#177) Feb 15, 2020
message Add Forwarder component (#187) Jun 4, 2020
pubsub Close all subscribers in TestConcurrentSubscribe (#178) Feb 19, 2020
tools/mill fmt and add required go version go gomod (#171) Dec 18, 2019
.gitignore Replace Travis with GitLab CI (#35) Feb 7, 2019
.golangci.yml Moved pub/subs implementations to separated repositories (#103) Jul 6, 2019
CONTRIBUTING.md Create CONTRIBUTING.md (#134) Sep 17, 2019
LICENSE Moved pub/subs implementations to separated repositories (#103) Jul 6, 2019
Makefile Better example verification (#108) Aug 7, 2019
README.md Add Synchronizing Databases example (#147) Nov 5, 2019
RELEASE-PROCEDURE.md Update RELEASE-PROCEDURE.md Sep 17, 2019
UPGRADE-0.3.md added UPGRADE-0.3.md (#48) Feb 13, 2019
UPGRADE-0.4.md Update docs (#73) May 14, 2019
UPGRADE-1.0.md Added changelog and some docs (#124) Sep 16, 2019
doc.go https://watermill.io/ docs (#18) Dec 12, 2018
go.mod Add Forwarder component (#187) Jun 4, 2020
go.sum Add Forwarder component (#187) Jun 4, 2020
log.go Added missing godocs (#177) Feb 15, 2020
log_test.go Kafka (and other) tests fix (#37) Feb 6, 2019
netlify.toml Added CQRS documentation (#46) Feb 13, 2019
uuid.go Update shortuuid library (#161) Nov 15, 2019
uuid_test.go Fixed Kafka races (#54) Feb 22, 2019

README.md

Watermill

CircleCI Go Report Card codecov

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.

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. Follow the Getting Started guide.
  2. See examples below.
  3. Read the full documentation: https://watermill.io/

Examples

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:

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:

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:

All Pub/Subs implementation documentation can be found in the documentation.

Contributing

Please check our contributing guide.

Stability

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).

Benchmarks

Initial tools for benchmarking Pub/Subs can be found in watermill-benchmark.

All benchmarks are being done on a single 16 CPU VM instance, running one binary and dependencies in Docker Compose.

These numbers are meant to serve as a rough estimate of how fast messages can be processed by different Pub/Subs. Keep in mind that the results can be vastly different, depending on the setup and configuration (both much lower and higher).

Here's the short version for message size of 16 bytes.

Pub/Sub Publish (messages / s) Subscribe (messages / s)
Kafka (one node) 63,506 110,811
Kafka (5 nodes) 70,252 117,529
NATS 76,208 38,169
SQL (MySQL) 7,299 154
SQL (PostgreSQL) 4,142 98
Google Cloud Pub/Sub 7,416 39,591
AMQP 2,408 10,608
GoChannel 272,938 101,371

Support

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.

Why the name?

It processes streams!

License

MIT License

You can’t perform that action at this time.