How to use the zeromq.Push function in zeromq

To help you get started, we’ve selected a few zeromq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeromq / zeromq.js / examples / threaded-worker / threaded-worker.ts View on Github external
if (code === 0) {
            resolve()
          } else {
            reject(new Error(`Worker stopped with exit code ${code}`))
          }
        })
      })
    })

    await Promise.all(workers)
    console.log("all workers stopped")
  }

  /* Queue only 1 incoming message. */
  input = new zmq.Pull({receiveHighWaterMark: 1})
  output = new zmq.Push()
  signal = new zmq.Subscriber()

  shift = 13
  maxDelay = 2000 /* Average of 1s. */

  constructor() {
    this.input.connect("inproc://input")
    this.output.connect("inproc://output")

    this.signal.connect("inproc://signal")
    this.signal.subscribe()

    const listen = async () => {
      for await (const [sig] of this.signal) {
        if (sig.toString() === "stop") this.stop()
      }

zeromq

Next-generation ZeroMQ bindings for Node.js

MIT
Latest version published 12 days ago

Package Health Score

87 / 100
Full package analysis