Ride Share Market - Free, accessible and open source Ride Sharing.
This git repository is the Node.js RabbitMQ RPC application for ridesharemarket.com.
A Node.js daemon processes json-rpc protocol messages from a RabbitMQ queue.
Processing is a request/reply model.
An example message from the RabbitMQ queue (the request):
{
jsonrpc: '2.0',
method: 'user.findById',
params: {
id: '542ecc5738cd267f52ac2085'
},
id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
}
An example reply to the RabbitMQ queue (the response):
{
"jsonrpc":"2.0",
"id":"f47ac10b-58cc-4372-a567-0e02b2c3d479",
"error":
{
"code":404,
"message":"not_found",
"data":"Account profile not found."
}
}
In between the request and response the Node.js application code does a database query.
Currently MongoDB is the database store.
- Listens for requests
- Validate input
- Process the request
- Return result
- Non Errors are simply the JSON-RPC property 'result'
- Errors are the JSON-RPC property 'errors' and have 3 properties which will map to JSON-API this way:
- code (JSON-RPC code => JSON-API HTTP status)
- message (JSON-RPC message => JSON-API code - Application/machine message)
- data (JSON-RPC data => JSON-API title - Human readable message)
RabbitMQ requires a vhost /rsm and a enabled user named rsm with a password.
MongoDB currently has no authentication implemented, access is restricted by IP address.
The defaults and examples assume RabbitMQ and MongoDB are running in a virtual machine at 192.168.33.10.
npm install -g gulp pm2cd ride-share-marketgit clone git@github.com:ride-share-market/data.gitcd datanpm install- Copy example environment configuration files
gulp init- Update the
env/*.jsonfiles where UPDATE is labeled.
gulp help
-
Local Dev workstation
-
gulp lint -
gulp watch-lint -
CI server
-
sudo docker exec -it rsm-jenkins bash -
export PATH=$PATH:/var/jenkins_home/tmp/iojs-v1.5.1-linux-x64/bin -
cd /var/jenkins_home/workspace/data/ -
./node_modules/mocha/bin/mocha --recursive app -
You may also send RPC message manually with
app/rpc/rpc-publisher-mongodb.js -
Example:
-
RABBITMQ_URL="rsm:UPDATE-THIS-PASSWORD@192.168.33.10/rsm" node rpc-publisher-mongodb.js -
Edit
app/rpc/rpc-publisher-mongodb.jsto alter the RPC message body.
-
Local Developer Environment
-
pm2 start config/pm2-loc.json -
VBX Env
-
sudo docker run -d --restart always --name rsm-data --env 'NODE_ENV=vbx' --cap-add SYS_PTRACE --security-opt apparmor:unconfined ride-share-market/rsm-data:x.x.x -
OR
-
cap vbx docker:deploy[data] -
PRD Env
-
cap prd docker:deploy[data]