simple-producer-consumer

1.2.2 • Public • Published

simple-producer-consumer

js-standard-style Build Status Code Climate codecov.io Dependency Status devDependency Status

NPM

A project to demonstrate bi-directional asynchronous network communication between independent Node.js processes.

A generator process creates random arithmetic expressions of 1 to 3 operations (2 to 4 operands) and sends the JSON formatted representation of the expression to an evaluator process which computes the value and replies to the generator. The generator and the evaluator communicate via websockets (facilitated by the Socket.io library).

Demonstration

asciicast

Requirements

  • Node.js v4.0.0 or later

Usage

Option 1 - Run generator and evaluator processes locally on same machine

# Install the npm module globally (may need to run as root via sudo) 
$ npm install simple-producer-consumer@latest -g
# Start the evaluator process 
$ spc-evaluator
# Start the generator process (in a different terminal window) 
$ spc-generator

Option 2 - Run the generator and connect to a hosted evaluator process running on an AWS EC2 server

# Install the npm module globally (may need to run as root via sudo) 
$ npm install simple-producer-consumer@latest -g
# Start the generator process (in a different terminal window) 
$ SPC_SERVER_HOST=ec2-52-35-48-3.us-west-2.compute.amazonaws.com spc-generator

Option 3 - Clone the repo, build the module and run without installing globally on your system

$ git clone git@github.com:cflynn07/simple-producer-consumer.git
cd ./simple-producer-consumer
$ npm install .
# Start the evaluator 
$ npm run evaluator
# Start the generator 
$ npm run generator

Tests

Unit tests use Mocha, Unit.js and Istanbul

$ npm run test
$ npm run test-html-cov # Will auto-open Google Chrome with test coverage data on OSX 

Configuration

Configuration options can be overriden by enviroment variables. Default values are defined in configs/.env

SPC_EXPRESSION_DISPLAY_COUNT=10
SPC_GENERATOR_INTERVAL=250
SPC_LOG_LEVEL_STDOUT=none
SPC_SERVER_HOST=localhost
SPC_SERVER_PORT=3001

UML Diagrams

Sequence

UML_Sequence

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i simple-producer-consumer

Weekly Downloads

1

Version

1.2.2

License

MIT

Last publish

Collaborators

  • cflynn07