betta-rpc

a lightweight RPC build on top of redis queues

npm install betta-rpc
1 downloads in the last week
4 downloads in the last month

betta-rpc - lightweight redis rpc on nodejs

a lightweight RPC build on top of redis queues.

  • Tags: node.js

Installation

npm install betta-rpc

Usage

Server

var bettarpc = require('betta-rpc');

var server = new bettarpc.Server({
  host: 'localhost',
  port: 6379,
  namespace: 'chat_server',
})

server.serve({
  halo: function(say, reply){
    reply(null, say + ' wow');
  },

  bye: function(reply){
    reply(null, 'bye');
  }
});

Client

var bettarpc = require('betta-rpc');

var client = new bettarpc.Client({
    host: 'localhost',
    port: 6379,
    namespace: 'chat_server',
    timeout: 10
  });

  client.connect(function(err, c){

    c.invoke('halo', 'hi1', function(err, res){
      if(err){
        console.error(err);
      }
      else{
        console.log('resp:', res);
      }
    });

    c.invoke('bye');
  });
npm loves you