NOTE: This should be hosted in a separate gist. The candidate will not be able to access this repository.
The New York Times hosts a simple, RESTful FIFO queueing service at:
https://nyt-techhiring-prd.ue.r.appspot.com
Its Swagger documentation is available at:
https://nyt-techhiring-prd.ue.r.appspot.com/v1/docs/
Your challenge is to use this existing API to implement a one-way teletype, or in modern terms, a one-way text-messenger. Feel free to implement this in any way you see fit--we've included animations of both a command-line solution and a browser solution at the end of this document.
Before we begin, select an alphanumeric [a-zA-Z0-9] queue ID to use. This API has no authentication, so we'll just pass our messages through a queue ID unique enough to not collide with other candidates currently using this (public) API.
-
Begin by writing the
sender
. It should take user text input and, each time the user hits Enter or "send", should submit it to the queue (as a string). You may use the command line, a web form, or any other interface you see fit for providing text input. -
Continue on to writing the
receiver
. It should display the contents of your queue using the API's GET endpoint. When invoked, it should display all the queue's contents (from the beginning of time); there's no need to store your "offset" between separate runs. Keep in mind, the GET API is paginated using anoffset
parameter. -
Finally, connect the two components into into our teletype text-messenger. The goal is that all typed text is transmitted from the sender to the receiver (see the below animations). Use whatever means/timing you deem appropriate to print new elements as they arrive over time. There's no need to persist your position in the queue between separate invocations.
When complete, your tool(s) should look a bit like one of the following figures: