Distributed Procedure Calls using AMQP
This library provides a super easy way to declare and call remote functions from your services. You can run a single instance or scale to thousands. It's up to you!
Do you want to use callbacks, promises or async/await? All covered!
Instances do not need to be aware of each other's existence. The first instance that is available to pick up the function call, will process it, and send back the results. This way, remote procedure calls (rpc) will be handled in a distributed system: distributed procedure calls (dpc).
The library uses AMQP to setup communication between the instances. You need to have a compatible message broker available like RabbitMQ.
The fastest way to get started is by signing up for a service that hosts RabbitMQ for you, like CloudAMQP. No configuration needed, and with the free plan, you get plenty for free.
Alternatively, you can install RabbitMQ on you local machine. Refer to "Downloading and Installing RabbitMQ" for the different installation methods depending on your environment.
npm i dpc
This is a full example on how to use the library to connect to a broker, register a function, and execute this function.
If you only run a single instance of this snippet, the function will actually be executed on the same instance that was calling the function. When multiple versions of this snippet are running, any of the attached instances could execute the function.
const DPC =// create a new dpc instanceconst dpc =// connect to the brokerdpc
See the API.md file for details.
If you would like to help out with some code, check the details.
Not a coder, but still want to support? Have a look at the options available to donate.