Instead of having to manage a separate distributed key store like etcd or ZooKeeper, leverage AWS's own Dynamodb so you don't have to worry about hardware provisioning, setup and configuration, replication, software patching, or cluster scaling.
As the only dependency is Dynamodb, it has the added benefit of allowing service discovery between applications running on EC2 and dockerized applications running within ECS.
Wanting to leverage as much of the managed AWS services as possible - less to go wrong (hopefully). Also a good exercise in using the AWS SDK for Go - there's not many examples out there using Dyanamodb from Go using the offical SDK, so seemed like a good project to try it out.
- Go 1.5 or above
- AWS credentials setup as per AWS SDK documentation. It seems the Go SDK needs credentials even for 100% local access; however these can be dummy values (see the example Docker Compose yml file.)
Within the examples folder there is an example echo client and server that demonstrate basic registry and discovery. Ensuring you have Docker Compose installed, simply run docker-compose up
. This creates 1 client and 2 instances of the server service - when one of these servers is stopped, the client should remain operational and shouldn't drop any requests.
The easiest way to get a local instance of Dynamodb running is to pull down this docker image. Then the following steps (assumes Docker Machine is being used with default name):
docker pull tutum/dynamodb
docker run -d -p 8000:8000 tutum/dynamodb
- 'export DYNAMODB_PORT=http://$(docker-machine ip default):8000'
- Run your Go app.
This is very much experimental at present...so please feel free to contribute any bugs (and even better PR's with fixes!)
- Clone the repository
- Install Glide which is used to handle vendoring and dependency management
- Install dependencies
$ glide install
go test .
will run tests. By default the tests will connect to the Amazon hosted Dynamodb in the default region. You can override the region by setting AWS_REGION
environment variable as per the AWS SDK. Also if the DYNAMODB_PORT
environment variable is set, tests will be run against the local dynamodb instance.