/events-breakfast-demo

Demo to go with https://eggybits.com/posts/events-first 🍳🥞

Primary LanguageTypeScript

🥞 eggybytes/events-breakfast-demo 🥞

An example of two microservice architectures: a synchronous, coupled request/response approach and an asynchronous, less-coupled event-driven approach.

For more:

Contents

Tools needed

Set up bazelisk:

brew tap bazelbuild/tap
brew install bazelisk

Verify that bazel points to bazelisk:

$ which bazel
/usr/local/bin/bazel
melinda at mmbp in ~/events on ml-add-bazel*
$ ls -l /usr/local/bin/bazel
lrwxr-xr-x  1 melinda  admin  34 May  11 11:33 /usr/local/bin/bazel -> ../Cellar/bazelisk/1.6.1/bin/bazel

Minikube setup

Install minikube, make Hyperkit the default driver, and give it more than the default amount of RAM:

brew install minikube
minikube config set driver hyperkit
minikube config set memory 2048 # 2 GB

To start minikube:

minikube start

To stop minikube:

minikube stop

Frontend tools

Install Yarn and Node if you don't have them.

Then install the dependencies for the frontend app:

# from the js/ directory
yarn install

How to build and run

Deploy Kafka to minikube

This deploys a clean version (nothing specific to this demo) of Kafka and Zookeeper to Kubernetes.

kubectl apply -f deployments/kafka.yaml

Create our Kafka topic

kubectl exec -it kafka-0 -- bash
# from kafka/local/topics.sh
/opt/kafka/bin/kafka-topics.sh --create --partitions 2 --replication-factor 1 --zookeeper zookeeper:2181 --topic order.order

Run the synchronous version of the microservices

bazel run //go/services/order-sync:api
bazel run //go/services/payment:api
bazel run //go/services/delivery:api

Run the asynchronous version of the microservices

bazel run //go/services/order-async:api
bazel run //go/workers/payment:worker
bazel run //go/workers/delivery:worker

Build the webapp

To build the breakfast-webapp app:

# from the js/ directory
yarn build

Serve the webapp

To actually serve the breakfast-webapp app (won't work unless you build first):

# from the js/ directory
yarn start

Clean up and destroy everything

minikube delete