API - acken/outbox-workshop GitHub Wiki

Below is the specifications of all the API's exposed from the services in this system.

Discovery Service

Register a service in the Discovery Service
POST /discovery/register { "type": "service type", "name": "service name", "heartbeat": "Full GET url responding with HTTP 200 OK. As an example: http://192.168.0.3:3031/heartbeat" }
RETURNS: 200, {}

Get a registered service from the Discovery Service
GET /discovery/:name
RETURNS: 200, ['http://192.168.0.3:3031']

Report a service that is misbehaving
POST /discovery/report
RETURNS: 200, {}

SMS Gateway Service

Heartbeat
GET /heartbeat
RETURNS: 200, { "tasksProcessed": tasksProcessedCount }

Endpoint for end users to to push temperature requests
POST /sms {"sender": "phone number", "message": "text message"}
RETURNS: 200, {}

Queue Service

Heartbeat
GET /heartbeat
RETURNS: 200, { "tasksProcessed": tasksProcessedCount }

Push temperature request to queue
POST /items {..ANY-JSON..}
RETURNS: 200, {}

Get temperature request from queue
GET /items/pop
RETURNS: 200, {..ANY-JSON-SENT-IN..}

Push temperature answer
POST /items {"sender": "phone number", "temperature": temperature}
RETURNS: 200, {}

Handler Service

Heartbeat
GET /heartbeat
RETURNS: 200, { "tasksProcessed": tasksProcessedCount }

The rest of this service is the recursive loop called serve which will continuously read from the queue and process messages if given any.

Weather Service

Heartbeat
GET /heartbeat
RETURNS: 200, { "tasksProcessed": tasksProcessedCount }

Finds the temperature for a location
GET /weather/:city
RETURNS: 200, { "temperature": temperature }