JSPM

stream-queue

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q31544F
  • License BSD

Distributed queue

Package Exports

  • stream-queue

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stream-queue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Distributed Queue

While not as cool as it sounds, it's a pretty straightforward server/client work queue that depends on JSON messages being exchanged to notify of work to be done and the status of that work.

npm install stream-queue

This is supposed to work with any nodejs streams. Your code is responsible for creating the streams and using the two main objects here to handle all the communication.

Basically, have a process to act as the server using the QueueMaster object to manage all the workers. You call addWorker(workerObj) to add a new worker. If a worker has been quiet for too long, it will be removed. You can also remove workers yourself if you want, such as when a socket disconnects.

The master keeps track of the list of jobs left to do, how many were originally assigned, etc.

The worker just wraps around whatever object you use to do the actual work. Your object has to implement a recvMsg(msg) and emit any messages it has as message events. The wrapper will convert everything to JSON and back, and pick up and send messages. Basically managing the queue.

There is some example code in the examples directory.