mvn spring-boot:run
mvn clean -U verify
mvn clean -U install
Every Time a new transaction happened, this endpoint will be called.
POST /transactions
{
"amount": 12.3,
"timestamp": 1478192204000
}
Field | Description |
---|---|
amount |
Transaction amount |
timestamp |
Transaction time in epoch in millis in UTC time zone (this is not current timestamp) |
Http Status | Description |
---|---|
201 | Transaction successfully added |
204 | Transaction is older than 60 seconds |
Get the statistic based on the transactions which happened in the last 60 seconds.
GET /statistics
{
"sum": 1000,
"avg": 100,
"max": 200,
"min": 50,
"count": 10
}
Field | Description |
---|---|
sum |
Is a double specifying the total sum of transaction value in the last 60 seconds |
avg |
Is a double specifying the average amount of transaction value in the last 60 seconds |
max |
Is a double specifying single highest transaction value in the last 60 seconds |
min |
Is a double specifying single lowest transaction value in the last 60 seconds |
count |
Is a long specifying the total number of transactions happened in the last 60 seconds |
# Configure port to use
server:
port: 9000
# Precision in millisecods to calculate statitics.
# Min value 1
# Max value 1000
statistics.precision-milliseconds: 10
mvn clean package docker:build
docker-compose up