1.0.18 • Published 7 years ago

nodik-zmq v1.0.18

Weekly downloads
22
License
ISC
Repository
github
Last release
7 years ago

nodik-zmq

Deprecated !!!

Further development is happening on zeronode npm package.
Contact Steadfast.tech Team if you need a help on how to use nodik-zmq and also zeronode.

How to install

npm install node-zmq

With nodik-zmq its easy to create server(s) <---> server(s) communication (e.g microservices).

let layerA = new Node({ bind: 'tcp://127.0.0.1:6001', layer: 'A'});
let layerB = new Node({ bind: 'tcp://127.0.0.1:6002', layer: 'B'});

// ** bind nodiks to a port to listen
await layerA.bind();
await layerB.bind();

//** connect one nodik to another nodik with address
await layerA.connect(layerB.getAddress());

// ** attach event listener to nodik layerB
layerB.onTick('welcome', (data) => {
    console.log('onTick - welcome', data);
});

// ** tick() is like firing an event to another node
layerA.tick(layerB.getId(), 'welcome', 'B');

// ** attach request listener to nodik layerB
layerB.onRequest('welcome', (data) => {
    console.log('onRequest - welcome', data.body);
    data.reply("Hello A");
});

// ** you request to another nodik and getting a promise
// ** which will be resolve after  data.reply("Hello A");
let responseFromB = await layerA.request(layerB.getId(), 'welcome', 'B');
console.log(responseFromB);
// responseFromB is "Hello A"

You can create various layers(groups) of nodik-s, connect nodiks together, proxy events and request from one nodik to another.

layerA.proxyRequest(fromEndpoint, tonNodeId, toEndpoint, timeout);

layerA.proxyTick(eventToProxy, tonNodeId, timeout);

(Under the hood we are using http://zeromq.org/ -s Dealer and Router sockets.)

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago