The assignment is to build a simple Producer/Consumer system. In this system the Generator will send a series of random arithmetic expressions, while the Evaluator will accept these expressions, compute the result and then report the solution to the Generator.
- NodeJS
- npm
- Run
npm install
The Consumer service listens for expressions from any Producers. Upon receiving an expression, it will attempt to evaluate it. If it's successful, it will emit an event back to the Producer with the answer. It will also emit the answer to the public event feed. If it can't evaluate the expression, it will broadcast an error instead.
- Run
npm run consumer
- Visit http://localhost:3000/ in a modern browser
Once the Consumer is running you can visit http://localhost:3000/ in a modern browser and get the expression interface. This page will be automatically updated as expressions from any Producers are evaluated as well as when expressions fail to be evaluated. The interface provides an input so you can manually enter your own expressions to have them evaluated live.
The Consumer will log all of it's output to stdout.
The Producer service will generate a random arithmetic expression consiting of two integers and an operator, e.g. "2+3=". It will do this every second until the end of time (or until you stop the process, whichever comes first). You can run as many Producer processes as your computer will support.
- Run
npm run producer
The Producer will log all of it's output to stdout.
You can freely deploy an instance of this application on Heroku to see it in action. Simply click the Heroku deploy button below and follow the instructions.
Once you have the app deployed on Heroku, you can increase the producer
dyno
to 1
to start a Producer service that will automatically start generating
random expressions and sending them to the Consumer based on the interval you
set for PRODUCER_INTERVAL
.
You can view a live demo at http://full-stack-challenge-example.herokuapp.com which has a Producer running on a 5 minute interval.
Use the npm test
command. This will validate the codestyle of the project
using tabs4life as well as
run all tests in the test
directory.
Use the npm run coverage
command to get the current code coverage report. It
will also attempt to upload it to Coveralls.io if you have permission.