This is an application suite simulating distributed microservices that track and persist GPS emission from vehicles. In a real world scenario this would probably be splitted in different projects, but for simplicity's sake this is a single project with all solutions.
All configuration is currently based on a development environment (which is defined in src/config/dev.js
) and assumes every transport-monitor
service (and their dependencies) are running in containers in a single docker-machine
(IP 192.168.99.100
). Make sure to set it up for your needs before running/building the application suite.
Each application execution is described below, but before running any of the following instructions, you must install dependencies or build the Docker image:
$ cd transport-monitor
$ npm install
$ cd transport-monitor
$ docker build -t transport-monitor .
The suggested approach for running this suite is to start the services in the following order:
Seeder
- Create Message Queue and generate fake vehicle dataGateway
- Receive GPS emissions and persist to a Message Queue systemConsumer
- Consume messages from queue, evaluates/validates and persist following business logicEmitter
- Send fake emissions for each car generated bySeeder
(once or each 20 seconds, based onEMITTER_RUN_ONCE
environment variable)
You don't have to worry about all this (nor building the Docker image or initializing dependency storage services such as ElasticMQ, MongoDB and Elasticsearch) and can simply execute run-with-deps
script:
$ sh run-with-deps.sh
Initializes project depedencies and generates 1000 fake vehicles and stores in a MongoDB vehicles
collection.
$ npm run seeder
> [email protected] seeder /Users/gmsecrieru/Projects/gmsecrieru/transport-monitor
> TASK_NAME=seeder babel-node src/index.js
[seeder] Done
$
$ docker run -it -e TASK_NAME=seeder transport-monitor
[seeder] Done
$
Emitter reads data persisted from Seeder
and sends a fake GPS emission to Gateway
.
$ npm run emitter
...
$
$ docker run -it -e TASK_NAME=emitter transport-monitor
Handles GPS emissions in an HTTP endpoint, which checks authorization and persists emission to a Message Queue for later processing.
$ npm run gateway
...
$
$ docker run -it -e TASK_NAME=gateway transport-monitor
Consumes GPS emissions from a Message Queue, validate and persist (or discard) information
$ npm run consumer
...
$
$ docker run -it -e TASK_NAME=consumer transport-monitor