A RPC over AMQP library for server-side JavaScript.
Beta. Server and Client API may change a bit.
Provide a language-agnostic RPC library to write distributed systems.
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.
var porthos = require('porthos/client_api');
function bootstrapClient(broker) {
porthos.createClient(broker, 'UserService').then((client) => {
// async call with return value.
client.call('doSomething').withJSON({foo: 'bar'}).async().then((response) => {
console.log('Got response: %s', response.content);
});
// void call.
client.call('doSomethingVoid').withArgs(1, 2).void();
})
};
porthos.createBroker(process.env.AMQP_URL).then(bootstrapClient).catch(console.warn);
Not implemented yet.
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:
$ docker-compose run client bash
root@porthos:/usr/src/app# node exampls/client.js