Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resolve-bus-zmq

Package Overview
Dependencies
Maintainers
1
Versions
603
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-bus-zmq - npm Package Compare versions

Comparing version 0.4.1-124084142.beta to 0.4.1-124150146.beta

140

dist/index.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

@@ -16,93 +16,93 @@

var defaultOptions = {
channel: 'DEFAULT',
address: '127.0.0.1',
pubPort: 2110,
subPort: 2111
channel: 'DEFAULT',
address: '127.0.0.1',
pubPort: 2110,
subPort: 2111
};
function runBroker(_ref) {
var address = _ref.address,
pubPort = _ref.pubPort,
subPort = _ref.subPort;
var address = _ref.address,
pubPort = _ref.pubPort,
subPort = _ref.subPort;
var subSock = _zeromq2.default.socket('xsub');
subSock.identity = 'subscriber' + process.pid;
subSock.bindSync('tcp://' + address + ':' + subPort);
var subSock = _zeromq2.default.socket('xsub');
subSock.identity = 'subscriber' + process.pid;
subSock.bindSync('tcp://' + address + ':' + subPort);
var pubSock = _zeromq2.default.socket('xpub');
pubSock.identity = 'publisher' + process.pid;
var pubSock = _zeromq2.default.socket('xpub');
pubSock.identity = 'publisher' + process.pid;
// ZMQ parameters described here http://api.zeromq.org/3-3:zmq-setsockopt
pubSock.setsockopt(_zeromq2.default.ZMQ_SNDHWM, 1000);
pubSock.setsockopt(_zeromq2.default.ZMQ_XPUB_VERBOSE, 0);
pubSock.bindSync('tcp://' + address + ':' + pubPort);
// ZMQ parameters described here http://api.zeromq.org/3-3:zmq-setsockopt
pubSock.setsockopt(_zeromq2.default.ZMQ_SNDHWM, 1000);
pubSock.setsockopt(_zeromq2.default.ZMQ_XPUB_VERBOSE, 0);
pubSock.bindSync('tcp://' + address + ':' + pubPort);
subSock.on('message', function (data) {
return pubSock.send(data);
});
pubSock.on('message', function (data) {
return subSock.send(data);
});
subSock.on('message', function (data) {
return pubSock.send(data);
});
pubSock.on('message', function (data) {
return subSock.send(data);
});
}
function getPublisher(_ref2) {
var address = _ref2.address,
subPort = _ref2.subPort,
channel = _ref2.channel;
var address = _ref2.address,
subPort = _ref2.subPort,
channel = _ref2.channel;
var sock = _zeromq2.default.socket('pub');
sock.connect('tcp://' + address + ':' + subPort);
return function (event) {
var message = channel + ' ' + event;
sock.send(message);
};
var sock = _zeromq2.default.socket('pub');
sock.connect('tcp://' + address + ':' + subPort);
return function (event) {
var message = channel + ' ' + event;
sock.send(message);
};
}
function buildConsumer(_ref3, trigger) {
var address = _ref3.address,
pubPort = _ref3.pubPort,
channel = _ref3.channel;
var address = _ref3.address,
pubPort = _ref3.pubPort,
channel = _ref3.channel;
var sock = _zeromq2.default.socket('sub');
sock.subscribe(channel);
sock.connect('tcp://' + address + ':' + pubPort);
sock.on('message', function (message) {
var data = message.toString().substring(channel.length + 1);
trigger(JSON.parse(data));
});
var sock = _zeromq2.default.socket('sub');
sock.subscribe(channel);
sock.connect('tcp://' + address + ':' + pubPort);
sock.on('message', function (message) {
var data = message.toString().substring(channel.length + 1);
trigger(JSON.parse(data));
});
}
function init(options, trigger) {
return Promise.resolve().then(function () {
return runBroker(options);
}).catch(function (err) {
return err;
}) // Broken may not run if already started
.then(function () {
var publisher = getPublisher(options);
buildConsumer(options, trigger);
return { publisher: publisher };
});
return Promise.resolve().then(function () {
return runBroker(options);
}).catch(function (err) {
return err;
}) // Broken may not run if already started
.then(function () {
var publisher = getPublisher(options);
buildConsumer(options, trigger);
return { publisher: publisher };
});
}
function createAdapter(options) {
var handler = function handler() {};
var config = _extends({}, defaultOptions, options);
var initPromise = init(config, function (event) {
return handler(event);
});
var handler = function handler() {};
var config = _extends({}, defaultOptions, options);
var initPromise = init(config, function (event) {
return handler(event);
});
return {
publish: function publish(event) {
return initPromise.then(function (_ref4) {
var publisher = _ref4.publisher;
return publisher(JSON.stringify(event));
});
},
subscribe: function subscribe(callback) {
return initPromise.then(function () {
return handler = callback;
});
}
};
return {
publish: function publish(event) {
return initPromise.then(function (_ref4) {
var publisher = _ref4.publisher;
return publisher(JSON.stringify(event));
});
},
subscribe: function subscribe(callback) {
return initPromise.then(function () {
return handler = callback;
});
}
};
}

@@ -109,0 +109,0 @@

{
"name": "resolve-bus-zmq",
"version": "0.4.1-0124084142.beta",
"version": "0.4.1-0124150146.beta",
"description": "This package is an adapter for resolve-bus to emit events using ZeroMQ.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc