go run cmd/main.go
or
go run cmd/main.go -reqs 15 -port 8081
docker build --tag stddev .
docker run -v /etc/ssl/certs:/etc/ssl/certs --net host stddev
or
docker build --tag stddev .
docker run -v /etc/ssl/certs:/etc/ssl/certs --net host stddev -reqs 15 -port 8081
-reqs number of requests per second
-port port number
Create a simple REST service in Go supporting the following GET operation:
/random/mean?requests={r}&length={l}
which performs {r}
concurrent requests to random.org API asking for {l}
number of random integers.
For each of {r}
requests, the service must calculate standard deviation of the drawn integers and additionally standard deviation of sum of all sets.
Results must be presented in JSON format.
GET /random/mean?requests=2&length=5
Response:
[
{
"stddev": 1,
"data": [1, 2, 3, 4, 5]
},
{
"stddev": 1,
"data": [1, 2, 3, 4, 5]
},
{ // stddev of sum
"stddev": 1,
"data": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]
}
]
- Proper error handling when communicating with external service (timeouts, invalid statuses).
- Usage of contexts.
- Solution should be delivered as a git repository.
- Provide a
.Dockerfile
that builds the image with the application. - Application should run flawlessly after running
docker build ...
&docker run ...
commands.