This is a REST API application which exposes necessary functionality to receive statistics and serve summary information.
The main use case for this application is to calculate realtime statistic from the last seconds specified in the configuration file. There are two APIs, one of them is called every time a transaction is made. It is also the sole input of this rest API. The other one returns the statistic based of the transactions of the last 60 seconds.
POST /transactions HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"amount": 110,
"timestamp": 1505252993000
}
201 - in case of success 204 - if transaction is older than 60 seconds
HTTP/1.1 201 Created
Content-Type: application/json
Request
GET /statistics HTTP/1.1
Host: localhost:8080
Response
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
{
"count":2,
"sum":230.0,
"avg":115.0,
"min":110.0,
"max":110.0
}
Travis.CI is used for continuous testing. for builds
To test:
mvn clean test
In order to build this application, run the following maven command.
mvn clean package
MIT