/consistent_service

Service discovery, consistent hashing, data duplication

Primary LanguageGo

Consistent Service

This library provides

Prerequisite

  1. Install docker on your machines

  2. Launch an etcd cluster

Do it your way or the easiest way via etcd_docker

  1. Install registrator on all machines in the cluster
docker run -d --name=registrator --net=host --volume=/var/run/docker.sock:/tmp/docker.sock
  gliderlabs/registrator etcd://<your etcd endpoint ip:port>/services

Note: all services will be registered under etcd's /services keyspace.

Run example

Start a few busybox containers with different ports

docker run -it -p 8081:8081 busybox
docker run -it -p 8082:8082 busybox

Go to example dir and

go run main.go --endpoints=http://<your etcd endpoint ip:port> --service_name=/services/busybox

Then stop/restart a few containers and check how a service node is assigned accordingly.