0.9.3 • Published 3 years ago
@spectacles/brokers v0.9.3
Spectacles brokers
A unified event publishing API to allow simple and powerful communication between services. Available brokers:
- AMQP - connects to an AMQP server
- Local - keeps events on a local event emitter
- Redis - connects to a Redis v5 server
- IPC - connects multiple node processes using native IPC sockets
How to use
const { Amqp } = require('@spectacles/brokers');
const broker = new Amqp('some group name');
(async () => {
  broker.on('hello', (data, { ack, reply }) => {
    ack();
    reply(`hello ${data}`);
  });
  broker.on('foo', (data, { ack }) => {
    ack();
    console.log(data);
  });
  await broker.connect('localhost');
  await broker.subscribe([
    'hello',
    'foo',
  ]);
  console.log(await broker.call('hello', 'world')); // hello world
  await broker.publish('foo', 'bar'); // bar
})();Obviously this is intended for use across multiple separate applications, where you publish in one app and subscribe in another.
Note: When publishing data on AMQP, you should call Amqp#createQueue(event) for every event you intend to publish.
This will create the queue and ensure your events aren't dropped.
0.9.3
3 years ago
0.9.2
3 years ago
0.9.1
3 years ago
0.9.0
4 years ago
0.8.4
5 years ago
0.8.3
5 years ago
0.8.2
5 years ago
0.8.1
5 years ago
0.8.0
5 years ago
0.7.2
6 years ago
0.7.1
6 years ago
0.7.0
7 years ago
0.6.1
7 years ago
0.6.0
7 years ago
0.5.0
7 years ago
0.4.5
7 years ago
0.4.4
8 years ago
0.4.3
8 years ago
0.4.2
8 years ago
0.4.1
8 years ago
0.4.0
8 years ago
0.3.0
8 years ago
0.2.0
8 years ago
0.1.0
8 years ago