Just playing with microservices in Golang.
Three containers share the same network. They work together to produce the result.
Generator can generate some response based on request HTTP POST parameters in JSON format:
"length"
(integer)"caps"
(boolean)
docker build -t mikegordo/generator generator/
docker run -p 8080:8080 --rm --name generator mikegordo/generator
curl -i -X POST -d "{\"length\":10, \"caps\":false}" localhost:8080
{
"Status":true,
"ErrorCode":200,
"Value":"idcgkvepqs"
}
Fetches the response from the Generator every FETCHER_FREQ
seconds (default 5) and stores it to Redis.
Uses environment variables FETCHER_LENGTH
(default 16) and FETCHER_CAPS
(default false).
docker build -t mikegordo/fetcher fetcher/
First, start Generator, then Redis container.
docker run --name redis --net container:generator --rm redis
Start the app
docker run --rm --name fetcher --net container:generator mikegordo/fetcher
Example with variables
docker run --rm --name fetcher --net container:generator -e FETCHER_LENGTH=8 -e FETCHER_CAPS=true mikegordo/fetcher