squiddy

0.2.7 • Public • Published

ipc network for microservices on local machine (unix sockets)

Install

$ npm install squiddy

Usage

run the hub process

$ node node_modules/squiddy/hub.js

instantiate a link in a process to make it a client

const ServiceLink = require('squiddy').link
const link = new ServiceLink("this-service")
 
link.connect()
.then(() => link.waitFor("another-service"))
.then(() => {
    console.log("found another-service")
})

create a request method

link.addRequestMethod("my-request-method", executeFunction)

(function can syncronous or asyncronous)

call a request method

link.request("another-service", "my-request-method")
.then(response => {
})

or, with arguments:

link.request("another-service", {
    method: "my-request-method",
    args: [...myArgs]
})

create a channel

link.createChannel("myChannel", onSubscribeFunction)

broadcast from a channel

link.broadcast("myChannel", channelMessage, specificSubscriber)
// if specificSubscriber is undefined then this broadcasts to all subscribers

subscribe to a channel

link.subscribe("another-service", "myChannel", callback)

or, for multiple actions for a subscription:

link.onChannelMessage("another-service", "myChannel", callback1)
link.onChannelMessage("another-service", "myChannel", callback2)

License

MIT

Package Sidebar

Install

npm i squiddy

Weekly Downloads

1

Version

0.2.7

License

ISC

Unpacked Size

23.2 kB

Total Files

17

Last publish

Collaborators

  • geofholbrook