npm i --save node-dot
You can also clone this repository and make use of it yourself.
git clone https://github.com/dot-microservices/dot.git cd dot npm i npm test
There are 2 simple components:
Documentation lines are not included to LOC values.
Server will automatically manage routing between client and Service instances. String responses are reserved for errors. If you send a string back, it means that an error occured. Client is for sending requests.
To have a better understanding on error types, there are a few more things to explain. A service is the name of your Service class in camel-case form and each static function in that class is called method. On client-side, you need to concatenate service name and method with delimiter as path. Default delimiter is a single dot(.). You can configure that by delimeter parameter.
const Server = require('node-dot').Server; class SampleService { static test(request, reply) { reply(request); } } const server = new Server(); server.addService(SampleService); server.start();
const Client = require('node-dot').Client; const client = new Client(); client.send('sampleService.test', request, response => { console.log(response); });
Test device specifications:
First, you should start server instance. Then execute following command:
node tests/benchmark.js
Your results should be similar to following values:
total time spent for 25000 requests is 0.98 seconds min processing time is 0.20 seconds max processing time is 0.76 seconds average processing time is 0.46 seconds