Skip to content

porthos-rpc/porthos-js

Repository files navigation

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.

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);

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:

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

About

A RPC over AMQP library for server-side JavaScript.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published