项目作者: porthos-rpc

项目描述 :
A RPC over AMQP library for server-side JavaScript.
高级语言: JavaScript
项目地址: git://github.com/porthos-rpc/porthos-js.git
创建时间: 2016-08-06T22:34:52Z
项目社区:https://github.com/porthos-rpc/porthos-js

开源协议:Other

下载


Porthos

A RPC over AMQP library for server-side JavaScript.

Status

Build Status

Beta. Server and Client API may change a bit.

Goal

Provide a language-agnostic RPC library to write distributed systems.

Client

The client is very simple. The method porthos.createClient takes a broker, a service name and a timeout value (request message TTL). The service name is only intended to serve as the request routing key (meaning every service name (or microservice) has its own queue). Each client declares only one response queue, in order to prevent broker’s resources wastage.

  1. var porthos = require('porthos/client_api');
  2. function bootstrapClient(broker) {
  3. porthos.createClient(broker, 'UserService').then((client) => {
  4. // async call with return value.
  5. client.call('doSomething').withJSON({foo: 'bar'}).async().then((response) => {
  6. console.log('Got response: %s', response.content);
  7. });
  8. // void call.
  9. client.call('doSomethingVoid').withArgs(1, 2).void();
  10. })
  11. };
  12. porthos.createBroker(process.env.AMQP_URL).then(bootstrapClient).catch(console.warn);

Server

Not implemented yet.

Contributing

Pull requests are very much welcomed. Make sure a test or example is included that covers your change.

Docker is being used for the local environment. To build/run/test your code you can bash into the server container:

  1. $ docker-compose run client bash
  2. root@porthos:/usr/src/app# node exampls/client.js