Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@skyring/zmq-transport

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skyring/zmq-transport

ZeroMQ Transport for Skyring

latest
Source
npmnpm
Version
4.0.1
Version published
Weekly downloads
4
-84%
Maintainers
3
Weekly downloads
 
Created
Source

skyring-zmq-transport

A ZMQ based transport for Skyring using PUSH or PUB zmq socket types. Specify the type of socket for the connection with the method field when creating a timer

Installation

$ npm install @skyring/zmq-transport --save

Usage

Skyring accepts an array property transports. Each entry can be a string or a named function. If given a string, skyring will pass it to require which must resolve to a named function

const Skyring = require('skyring')
const server = new Skyring({
  transports: ['@skyring/zmq-transport']
, seeds: ['localhost:3455']
})

server
  .load()
  .listen(3000)

Example Echo Server

'use strict'

const zmq = require('zmq')

let count = 0
const port = process.env.PORT || 5555
const socket = zmq.socket('pull')
socket.connect(`tcp://0.0.0.0:${port}`)
socket.on('message', (evt, chunk) => {
  console.log(`${++count} ` + chunk)
})
process.once('SIGINT', onSignal)
process.once('SIGTERM', onSignal)
function onSignal() {
  socket.disconnect(`tcp://0.0.0.0:${port}`)
  socket.close()
}
$ curl -XPOST http://localhost:3000/timer -H 'Content-Type: application/json' -d '{
  "timeout":3000
, "data":"hello world!"
, "callback": {
    "transport": "zmq"
  , "method":"push"
  , "uri": "tcp://0.0.0.0:5555"
  }
}'
>>> 1 hello world !

FAQs

Package last updated on 17 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts