Skip to content

minghsu0107/golang-taipei-watermill-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watermill Example

This is a tutorial on building event-driven application in Golang using Watermill, a fantastic Go library for working efficiently with message streams.

Overview

We run a publisher in the background, publishing messages to the message broker on topic incoming_topic every 3 seconds. At the same time, helloHandler and incomingTopicHandler subscribe on topic incoming_topic; outgoingTopicHandler subscribes on outgoing_topic. Once helloHandler receives a message, it will then publish another greeting message to topic outgoing_topic, which will be recived by outgoingTopicHandler.

In transport.go, we decouple our service logics from the broker implementation. That is, we are able to switch to any message broker without changing existing code as long as the broker client implements message.Publisher and message.Subscriber interface.

Usage

docker-compose up

We can switch to GoChannel Pub/Sub by simply setting WATERMILL_PUBSUB_TYPE to empty string.

About

A demonstration on building event-driven application, @ Golang Taipei Short Talk, Feb 2021.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages