ric-utils-rabbit-rpc
v1.0.16
Published
RPCv1 service communication
Downloads
19
Readme
ric-utils-rabbit-rpc
Install
npm i --save-dev ric-utils-rabbit-rpc
npm shrinkwrap
Usage
Client
const rpc = require('ric-utils-rabbit-rpc').Client;
const rabbit = app.interfaces.transport.rabbitmq;
const client = new rpc.Client(
'ric.<service>.control',
'ric.<service>.replies');
client.connect(rabbit);
client.call('some-method', {param1 : 'a', param2 : 'b'}, (err, res) => {
console.log('err', err);
console.log('res', res);
});
V2
Usage
<Object RpcController>.getClient(<name service to receive calls>);
Example: for creation client from call methods service ric-handler
need
paste this code:
...
const handlerRpc = rpcManager.getClient('ric-handler');
handlerRpc.call('get-handlers', (err, result) => {
if (err) {
return console.log(err); // if call was finished with errors
// print type error, for example:
// 'Internal error', 'Parse error' or other
// error type
}
console.log(result); // if call was finished success:
// [
// '<handler #1>',
// '<handler #2>',
// ...]
});