To run it:
cd ./cmd/webserver
go run .
To test it:
curl http://localhost:8080/todos
=> workingcurl http://localhost:8080/todo?id=1
=> workingcurl http://localhost:8080/todo?id=11
=> not found
To build it:
docker build -t webserver .
To run a container:
docker run -p 8080:8080 webserver
To run it:
docker run --name graphite --restart=always -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
To query metrics: Enconding:
- "'" => %27
- "," => %2C
curl "http://0.0.0.0:80/render?target=consolidateBy(webserver.get_todos.success%2C%27sum%27)&from=-1h&format=json"
curl "http://0.0.0.0:80/render?target=removeEmptySeries(webserver.get_todos.success%2C0.1)&from=-1h&format=json"
curl "http://0.0.0.0:80/render?target=consolidateBy(webserver.get_todos.success%2C%27sum%27)&from=-10min&format=json"
curl "http://0.0.0.0:80/render?target=maxSeries(webserver.get_todos.success)&from=-10min&format=json"
curl "http://0.0.0.0:80/render?target=removeBelowValue(webserver.get_todos.success%2C1)&from=-15min&format=json"
curl "http://0.0.0.0:80/render?target=removeBelowValue(transformNull(webserver.get_todos.success)%2C0)&from=-60min&format=json"
curl "http://0.0.0.0:80/render?target=removeBelowValue(transformNull(webserver.get_todos.success)%2C%200)&format=json"
To build it:
docker-compose build --no-cache
To run it:
docker-compose up -d
To stop it:
docker-compose down --remove-orphans
To run it:
go test -v -tags=integration ./...
go test ./tests -tags=integration
-
docker-compose up -d
-
docker ps
=> you should see the two containers up & running -
go test ./tests -tags=integration
--- FAIL: TestGetTodos (0.86s) get_todos_test.go:17: Error Trace: $HOME/graphite-poc/tests/container.go:24 $HOME/graphite-poc/tests/get_todos_test.go:17 Error: Received unexpected error: compose up: Error response from daemon: Conflict. The container name "/graphite" is already in use by container "ceb36087cd8f58a82bdc07d755c36b7e1d043b5e4a670a37cf44c1947f6c7826". You have to remove (or rename) that container to be able to reuse that name. Test: TestGetTodos FAIL FAIL github.com/ossan-dev/graphitepoc/tests 7.805s FAIL
The fix for the code is contained in the commit with the message fixConflictContainers
. We try to spin up the containers again in case of an issue.