Skip to content
An example of an application that is designed for failure
Go Smarty Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
cmd
configs
internal
.dockerignore
.editorconfig
.gitignore
.travis.yml
Dockerfile_barista
Dockerfile_reception
LICENSE
Makefile
README.md
docker-compose.yml
go.mod
go.sum
skaffold.yaml

README.md

Coffee Shop

Build Status Go Report Card Godocs

This is a example of how we can design an application that is ready to handle unexpected events.

Getting Started

You can easily spin up the whole system by executing:

docker-compose up -d

This will setup our 2 services and will make sure they are talking to each other. If you want to play around with it and simulate failure you can run the failure scenarios.

Kubernetes deploy

If you really wanna see the power of a reliable service setup you should install the helm charts that are available.

helm install build/coffee-shop

This will setup:

  • HA rabbitMQ cluster
  • Postgres database with the migrations already applied
  • 2 instances load balanced of the reception service
  • 2 instances of the barista service that is listening to rabbitmq messages

Enable an ingress controller

helm install stable/nginx-ingress --name nginx-ingress \
    --set controller.stats.enabled=true \
    --set controller.metrics.enabled=true

You can access the coffee-shop reception endpoint at http://coffee-shop.local

Enable prometheus and grafana

helm install -f build/monitoring/grafana-values.yaml --name prometheus --namespace monitoring stable/prometheus-operator

You can access grafana at http://monitoring.local

Reception Service

Think about a coffee-shop. The first thing you normally do when you enter one is to go to the reception and order a coffee. Reception is the service that is getting new orders and sending to the barista to be done.

In this service we have:

  • RabbitMQ to send messages that are send with protocol buffers
  • Tracing and monitoring using open census
  • All calls to external dependencies are wrapped around a Circuit Breaker. You can use a Hystrix dashboard to check for the circuits.
  • To keep things simple, we mock the payments service with wiremock in a separate container where we can simulate failure when necessary.

Barista Service

Barista is the service that actually prepares your coffee and make sure you can have the best experience possible.

The barista will get an order request from RabbitMQ and start preparing your coffee. Once the coffee is ready another message is published and whoever want's to interact with that will be able to.

Simulating Failure

Breaking the message broker

docker-compose stop rabbitmq
make orders
You can’t perform that action at this time.