0.0.18 • Published 9 years ago

bograch v0.0.18

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Bograch

Dependency Status Build Status

Bograch is a tool for abstracting RPC (remote procedure call) communication between/with NodeJS microservices.

Usage

Add a transporter.

var bo = require('bograch');
var AmqpTransporter = require('bograch-amqp');

bo.use(new AmqpTransporter({
  amqpURL: 'amqp://guest:guest@localhost:5672'
}));

Create a microservice for mathematical calculations and implement some remote methods.

var server = bo.server('amqp', {
  name: 'mathOperations'
});

server.on('sum', function (a, b, cb) {
  cb(null, a + b);
});

server.on('factorial', function (n, cb) {
  var f = 1;
  for (var i = 2; i <= n; i++) {
    f *= i;
  }
  cb(null, f);
});

Create a client for the math microservice and call some of its remote methods.

var client = bo.client('amqp', {
  name: 'mathOperations'
});
client.register(['sum', 'factorial']);

var Math = client.methods;

Math.sum(12, 2, function (err, sum) {
  console.log(sum);
});

Math.factorial(10, function (err, result) {
  console.log(result);
});

License

The MIT License (MIT)

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago