npm.io
2.0.1 • Published 7 years ago

@fofx/queue

Licence
MIT
Version
2.0.1
Deps
3
Size
8 kB
Vulns
1
Weekly
0

queue

Pure node implementation of a distributed queue

Usage

// broker.js
const { startQueueBroker } = require('@fofx/queue').distributed;
const { add } = startQueueBroker(9000);
add({ x: 1, y: 2 }).then(value => console.log(value));
// worker.js
const { startQueueWorker } = require('@fofx/queue').distributed;
const worker = startQueueWorker('ws://localhost:9000');
worker.register(async function add({ x, y }) {
  const constant = await worker.get('const', 0);
  const value = x + y + constant;
  await worker.set('const', value);
  return x + y;
});