New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zerorpc

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zerorpc - npm Package Compare versions

Comparing version 0.9.3 to 0.9.4

37

lib/channel.js

@@ -42,4 +42,2 @@ // Open Source Initiative OSI - The MIT License (MIT):Licensing

//Heartbeat rate in milliseconds
var HEARTBEAT = 5000;

@@ -56,8 +54,11 @@ //Creates a new channel

// The channel buffer's capacity
function Channel(id, envelope, socket, capacity) {
this.id = id;
this._state = CHANNEL_OPEN;
this._envelope = envelope;
this._socket = socket;
this._capacity = capacity;
//heartbeatInterval: Number
// The heartbeat interval in ms
function Channel(id, envelope, socket, capacity, heartbeatInterval) {
this.id = id;
this._state = CHANNEL_OPEN;
this._envelope = envelope;
this._socket = socket;
this._capacity = capacity;
this._heartbeatInterval = heartbeatInterval

@@ -152,3 +153,3 @@ //Setup heartbeating on the channel

if(this.state == CHANNEL_CLOSING && this._outBuffer.length() == 0) {
if(this._state == CHANNEL_CLOSING && this._outBuffer.length() == 0) {
this._state = CHANNEL_CLOSED;

@@ -195,3 +196,3 @@ delete this._socket.channels[this.id];

//error
self.emit("heartbeat-error", "Lost remote after " + (HEARTBEAT * 2) + "ms");
self.emit("heartbeat-error", "Lost remote after " + (self._heartbeatInterval * 2) + "ms");
self.close();

@@ -207,3 +208,3 @@ }

}
}, HEARTBEAT);
}, self._heartbeatInterval);
};

@@ -213,3 +214,3 @@

Channel.prototype._resetHeartbeat = function() {
this._heartbeatExpirationTime = util.curTime() + HEARTBEAT * 2;
this._heartbeatExpirationTime = util.curTime() + this._heartbeatInterval * 2;
};

@@ -235,4 +236,6 @@

// The capacity of the socket's input buffer
function ServerChannel(srcEvent, socket, capacity) {
Channel.call(this, srcEvent.header.message_id, srcEvent.envelope, socket, capacity);
//heartbeatInterval: Number
// The heartbeat interval in ms
function ServerChannel(srcEvent, socket, capacity, heartbeatInterval) {
Channel.call(this, srcEvent.header.message_id, srcEvent.envelope, socket, capacity, heartbeatInterval);
}

@@ -247,4 +250,6 @@

// The capacity of the socket's input buffer
function ClientChannel(socket, capacity) {
Channel.call(this, events.fastUUID(), null, socket, capacity);
//heartbeatInterval: Number
// The heartbeat interval in ms
function ClientChannel(socket, capacity, heartbeatInterval) {
Channel.call(this, events.fastUUID(), null, socket, capacity, heartbeatInterval);
this._fresh = true;

@@ -251,0 +256,0 @@

@@ -33,2 +33,5 @@ // Open Source Initiative OSI - The MIT License (MIT):Licensing

//Heartbeat rate in milliseconds
var DEFAULT_HEARTBEAT = 5000;
// Creates a new client

@@ -39,6 +42,9 @@ // options : Object

// considered timed out (default 30s)
// * heartbeatInterval (number): The heartbeat interval in ms.
// (default 5000ms)
function Client(options) {
options = options || {};
this._socket = socket.client();
var heartbeat = options.heartbeatInterval || DEFAULT_HEARTBEAT
this._timeout = options.timeout || DEFAULT_TIMEOUT;
this._socket = socket.client(heartbeat);

@@ -146,2 +152,2 @@ util.eventProxy(this._socket, this, "error");

exports.Client = Client;
exports.Client = Client;

@@ -31,2 +31,5 @@ // Open Source Initiative OSI - The MIT License (MIT):Licensing

// Heartbeat rate in ms
var DEFAULT_HEARTBEAT = 5000;
//Gets the arguments associated with a function as an array

@@ -73,6 +76,8 @@ //fun : Function

// The object to expose
function Server(context) {
var self = this;
function Server(context, heartbeat) {
var self = this
, heartbeat = heartbeat || DEFAULT_HEARTBEAT;
self._socket = socket.server();
self._socket = socket.server(heartbeat);
util.eventProxy(self._socket, self, "error");

@@ -82,2 +87,5 @@

context._zerorpc_ping = function(reply) { reply(null, ["pong",""]); };
self._methods._zerorpc_ping = [];
var newInspector = self._createIntrospector(context.constructor.name || "Object");

@@ -206,2 +214,2 @@

exports.Server = Server;
exports.Server = Server;

@@ -92,3 +92,3 @@ // Open Source Initiative OSI - The MIT License (MIT):Licensing

// The underlying ZeroMQ socket to use
function MultiplexingSocket(zmqSocket) {
function MultiplexingSocket(zmqSocket, heartbeat) {
Socket.call(this, zmqSocket);

@@ -99,2 +99,3 @@ var self = this;

self.channels = {};
self._heartbeatInterval = heartbeat

@@ -121,5 +122,5 @@ //Route events to a channel if possible; otherwise emit the event

if(srcEvent) {
var ch = new channel.ServerChannel(srcEvent, this, CHANNEL_CAPACITY);
var ch = new channel.ServerChannel(srcEvent, this, CHANNEL_CAPACITY, this._heartbeatInterval);
} else {
var ch = new channel.ClientChannel(this, CHANNEL_CAPACITY);
var ch = new channel.ClientChannel(this, CHANNEL_CAPACITY, this._heartbeatInterval);
}

@@ -145,12 +146,12 @@

//Creates a new multiplexing socket server
function server() {
return new MultiplexingSocket(zmq.socket("xrep"));
function server(heartbeat) {
return new MultiplexingSocket(zmq.socket("xrep"), heartbeat);
}
//Creates a new multiplexing socket client
function client() {
return new MultiplexingSocket(zmq.socket("xreq"));
function client(heartbeat) {
return new MultiplexingSocket(zmq.socket("xreq"), heartbeat);
}
exports.server = server;
exports.client = client;
exports.client = client;
{
"name": "zerorpc",
"version": "0.9.3",
"version": "0.9.4",
"main": "./index.js",

@@ -15,3 +15,5 @@ "author": "dotCloud <opensource@dotcloud.com>",

}],
"scripts": {
"test": "./node_modules/.bin/nodeunit test"
},
"repository": {

@@ -31,3 +33,3 @@ "type": "git",

"underscore": "1.3.3",
"msgpack": "0.1.8",
"msgpack": "0.2.6",
"node-uuid": "1.3.3",

@@ -38,3 +40,3 @@ "zmq": "2.x"

"devDependencies": {
"nodeunit": "0.7.4"
"nodeunit": "0.9.1"
},

@@ -41,0 +43,0 @@

zerorpc-node
============
ZeroRPC is a communication layer for distributed systems. zerorpc-node is a port of the original [ZeroRPC](https://github.com/dotcloud/zerorpc-python) for node.js. We have full client and server support for version 3 of the protocol, and clients/servers written in the Python version can communicate transparently with those written in node.js. This project is alpha.
ZeroRPC is a communication layer for distributed systems. zerorpc-node is a port of the original [ZeroRPC](https://github.com/dotcloud/zerorpc-python) for node.js. We have full client and server support for version 3 of the protocol, and clients/servers written in the Python version can communicate transparently with those written in node.js. This project is in alpha.

@@ -18,5 +18,15 @@ To install the package:

var zerorpc = require("zerorpc");
var server = new zerorpc.Server(context);
var server = new zerorpc.Server(context [, heartbeat]);
The constructor takes in a context object with the functions to expose over RPC. Only functions that do not have a leading underscore will be exposed. Each exposed method must take in a callback as the last argument. This callback is called as `callback(error, response, more)` when there is a new update, where error is an error object or string, response is the new update, and more is a boolean specifying whether new updates will be available later. `error`, `response`, and `more` default to falsy values, so e.g. simply calling `callback()` closes an open stream, since `more` is false by default.
The constructor takes in a context object with the functions to expose
over RPC. Only functions that do not have a leading underscore will be
exposed. Each exposed method must take in a callback as the last
argument. This callback is called as `callback(error, response, more)`
when there is a new update, where error is an error object or string,
response is the new update, and more is a boolean specifying whether new
updates will be available later. `error`, `response`, and `more` default
to falsy values, so e.g. simply calling `callback()` closes an open
stream, since `more` is false by default. Constructor also takes a
heartbeat parameter that specifies the interval that the server should
ping clinets to let them know it is active.

@@ -72,2 +82,3 @@ Events:

* `timeout` (number) - Sets the number of seconds to wait for a response before considering the call timed out. Defaults to 30.
* `heartbeatInterval` (number) - Sets the number of miliseconds to send send heartbeats to connected servers. Defaults to 5000ms.

@@ -108,2 +119,4 @@ Events:

}
});
});

@@ -83,2 +83,2 @@ // Open Source Initiative OSI - The MIT License (MIT):Licensing

});
};
};
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