simple-rpc-client

1.3.0 • Public • Published

simple-rpc-client

Simple RPC client module based on AMQP/RabbitMQ.

Example

var simplerpc = require('./lib/simple-rpc');
 
var RABBITMQ_URL = 'amqp://guest:guest@localhost:5672';
 
simplerpc.connect(RABBITMQ_URL, function connected(err) {
    var remoteMethod = 'sum';
    var args = {
        a: 2,
        b: 3
    };
 
    simplerpc.call(remoteMethod, args, function callback(err, message) {
        logger.debug('got response', message);
    });
});

Timeouts

There is a 60-second timeout by default. You can pass any timeout you want to call. Once the timeout is reached, the callback will be called with an error.

    ...
    var TIMEOUT = 5000; // 5-second timeout
    simplerpc.call(slowRemoteMethod, args, TIMEOUT, function callback(err, message) {
        if (err) {
            // possible timeout
        } else {
            logger.debug('got response', message);
        }
    });

Development documentation

Coding guidelines

Uses provided .jshintrc and .gjslintrc flag files. To check source code style, type

grunt lint

Testing

To run tests, type

grunt test

/simple-rpc-client/

    Package Sidebar

    Install

    npm i simple-rpc-client

    Weekly Downloads

    5

    Version

    1.3.0

    License

    none

    Last publish

    Collaborators

    • palmerabollo