Skip to content
Code samples for the Go microservice blog series
Go Shell Makefile Dockerfile Java Scala
Branch: master
Clone or download
Latest commit 49f10de Jul 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
accountservice changed package pkg to app Jul 28, 2019
common fixed missing warnf Jul 27, 2019
dataservice minor fix Jul 28, 2019
dbloadtest
docker removed config server Jul 27, 2019
extras Added sample setup of swarm Mar 8, 2017
gelftail WiP fixing the master branch and introducing modules Jul 13, 2019
healthchecker Finished Part 6 Feb 6, 2017
imageservice minor fix Jul 28, 2019
loadtest WiP fixing the master branch and introducing modules Jul 13, 2019
support Huge refactoring, WiP Jul 14, 2019
swarm-prometheus-discovery Huge refactoring, WiP Jul 14, 2019
vipservice changed package pkg to app Jul 28, 2019
.gitignore Huge refactoring, WiP Jul 14, 2019
AWS.md Experimenting with AWS CloudFormation and Docker Stack Oct 12, 2017
LICENSE Initial commit Feb 5, 2017
Makefile changed package pkg to app Jul 28, 2019
README.md changed package pkg to app Jul 28, 2019
as.sh New bash script for quick rebuild and redeploy of the accountservice Sep 9, 2018
cockroachdb.sh Part 13, WiP code Feb 10, 2018
copyall.sh Final code for part 14 May 6, 2018
disc.sh Initial commit of P15 source May 26, 2018
docker-machine-ipconfig.sh Experimenting with AWS CloudFormation and Docker Stack Oct 12, 2017
docker-stack.yml Experimenting with AWS CloudFormation and Docker Stack Oct 12, 2017
dvizz.sh Source formatting and code for part 15 Sep 10, 2018
gelftail.sh Adding local copy of gelftail Feb 24, 2017
grafana.sh Source formatting and code for part 15 Sep 10, 2018
prometheus.sh Initial commit of P15 source May 26, 2018
pushall.sh
quotes-service.sh Work in progress, adding resilience and hystri Aug 31, 2017
springcloud.sh Fixing stuff for nov2017 seminar Nov 5, 2017

README.md

goblog

Code samples for the Go microservice blog series

Changelog

  • 2019-07-27: Total rewrite of Go code, including introducing Makefiles for build and a docker-compose file for deployment on Docker Swarm.

Some URLs to remember

Turbine stream URL: http://192.168.99.100:8282/turbine.stream?cluster=swarm Hystrix stream URL: http://accountservice:8181/hystrix.stream?cluster=swarm

Make sure Turbine doesn't crash on startup due to AMQ connection problem.

Setting up Docker Swarm cluster

docker-machine create --driver virtualbox --virtualbox-cpu-count 4 --virtualbox-memory 6000 --virtualbox-disk-size 30000 swarm-manager-0
eval "$(docker-machine env swarm-manager-0)"
docker network create --driver overlay my_network
docker swarm init --advertise-addr 192.168.99.100
Adding a worker node
docker swarm join --token SWMTKN-1-5njothki0tww7gestuh309qgrnr6r357phlsn7ue0r8qmlqnla-181tl1rfou16vv3e7nxrk4ra3 192.168.99.100:2377

Building

You need Go 1.12 or later installed on your system to build from source.

Builds are performed using Makefile(s). In the root /goblog folder:

make build

One can also run all tests, format code using makefile targets.

Deploying

Deploy using:

make deploy

The make target uses docker stack deploy behind the scenes.

Nice to haves

Here's some minor stuff worth remembering.

Running the CockroachDB client

Find a container running the cockroachdb/cockroach container using docker ps and note the container ID. Then we'll use docker exec to launch the SQL CLI:

> docker exec -it 10f4b6c727f8 ./cockroach sql --insecure

Create user and database for Cockroach

(this is possibly broken, from part 16 onwards the initial DB setup is performed using the docker stack)

Originally from: https://github.com/cockroachdb/cockroach/issues/19826#issuecomment-358360851

DROP USER IF EXISTS cockroach; \
DROP DATABASE IF EXISTS account CASCADE; \
CREATE DATABASE IF NOT EXISTS account; \
CREATE USER cockroach WITH PASSWORD 'password'; \
GRANT ALL ON DATABASE account TO cockroach;
You can’t perform that action at this time.