0.1.1 • Published 4 years ago
@akiroz/pubsub-rpc v0.1.1
PubSub RPC
A generic RPC mechanism for Pub/Sub transports based on MsgPack
Supports NodeJS and modern browsers.
Installing
$ yarn add @akiroz/pubsub-rpcWhy not JSON-RPC?
Native binary support for passing large binary payloads.
Mechanism
- Callee subscribe to
topic - Caller subscribe to
topic/${base64(id)} - Caller publish to
topicwith a binaryid(default 16 byte) in the payload - Callee calls RPC handler with
paramsin the payload to getresultorerrorresponse - Callee publish response to
topic/${base64(id)} - Caller unsubscribe from
topic/${base64(id)}
API
See tests for a basic use case that simply uses an EventEmitter as the Pub/Sub mechanism.