© 2019  Just Tech

  • LinkedIn Social Icon
  • Instagram

Work sample
Svensk Travsport


We have built a simple trot race simulator that runs a new race with six horses every minute
of every day. When a horse starts or finishes, an event is sent out in real time via a REST
API. The task is to build a "worker" that subscribes to these events and saves them in a
MongoDB database.


The service uses long-polling. If no new events have been published within 15 seconds after
a request has been made, the request is cancelled and the service returns HTTP status 204.
Then the worker needs to make a new request.


We also wish that there will be one integration test against the database implemented.
Our intention is that an experienced developer should be able to complete this task in
relatively short time. Part of our interest lies in seeing how the code is organised.


The server does not buffer outgoing events. This means that the client may miss some
events that are sent out too fast. This is a limitation in the context of this work sample.

API
Endpoint: http://35.207.169.147/results

Events

 

Start

{
"event": "start",
"horse": {
"id": 8,
"horse": "Dazzle"
},
"time": 0
}

Goal

{
"event": "finish",
"horse": {
"id": 8,
"horse": "Dazzle"
},
"time": 13462
}