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

moray

Package Overview
Dependencies
Maintainers
15
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moray - npm Package Compare versions

Comparing version 3.7.0 to 3.8.0

.history/CHANGES_20200625093007.md

5

CHANGES.md
# Changelog
## v3.8.0
* [TRITON-2142](https://jira.joyent.us/browse/TRITON-2142) add listen() and
notify() APIs to allow use of PostgreSQL listen/notify features.
## v3.7.0

@@ -4,0 +9,0 @@

@@ -1040,2 +1040,57 @@ /*

/**
* Listens on the given channel for Postgresql notifications.
*
* @param {String} channel - Notification channel to listen on
* @param {Object} opts - Request Options
* @return {EventEmitter} - listen for 'notification', 'end' and 'error'
*/
MorayClient.prototype.listen = function _listen(channel, opts) {
var rv;
opts = opts || {};
assert.string(channel, 'channel');
assert.object(opts, 'opts');
var rpcctx = this.ctxCreateForEmitter();
if (rpcctx) {
rv = meta.listen(rpcctx, channel, opts);
this.releaseWhenDone(rpcctx, rv);
return (rv);
}
return (emitUnavailable());
};
/**
* Notify this channel with this payload.
*
* @param {String} channel - Notification channel to listen on
* @param {String} payload - Notification payload to send
* @param {Object} opts - Request Options
* @param {Function} cb - cb(err)
*/
MorayClient.prototype.notify = function _notify(channel, payload, opts, cb) {
assert.string(channel, 'channel');
assert.string(payload, 'payload');
if (typeof (opts) === 'function') {
cb = opts;
opts = {};
}
assert.func(cb, 'cb');
var rpcctx = this.ctxCreateForCallback(cb);
if (rpcctx) {
meta.notify(rpcctx, channel, payload, opts,
this.makeReleaseCb(rpcctx, cb));
} else {
cb(emitUnavailable());
}
};
/*

@@ -1042,0 +1097,0 @@ * A MorayRpcContext is a per-request handle that refers back to the Moray

74

lib/meta.js

@@ -20,4 +20,4 @@ /*

var libuuid = require('libuuid');
var jsprim = require('jsprim');
var events = require('events');
var stream = require('stream');
var VError = require('verror');

@@ -190,5 +190,77 @@

function listen(rpcctx, channel, options) {
var opts, log, req, res;
assert.object(rpcctx, 'rpcctx');
assert.string(channel, 'channel');
assert.object(options, 'options');
assert.optionalNumber(options.timeout, 'options.timeout');
opts = {
req_id: options.req_id || libuuid.create(),
timeout: options.timeout
};
log = rpc.childLogger(rpcctx, opts);
res = new stream.PassThrough({objectMode: true});
res.req_id = opts.req_id;
/*
* We specify ignoreNullValues because electric-moray sends spurious
* trailing null values from successful sql() commands. These are not
* generally allowed, but we have to maintain compatibility with broken
* servers.
*/
req = rpc.rpcCommon({
'rpcctx': rpcctx,
'rpcmethod': 'listen',
'rpcargs': [ channel, opts ],
'ignoreNullValues': true,
'log': log
}, function (err) {
if (err) {
res.emit('error', err);
} else {
res.emit('end');
}
res.emit('_moray_internal_rpc_done');
});
req.pipe(res);
// Add unlisten hook so clients can easily unlisten from the channel.
res.unlisten = function _listenUnlisten(cb) {
rpc.rpcCommonNoData({
'rpcctx': rpcctx,
'rpcmethod': 'unlisten',
'rpcargs': [ opts.req_id, opts ],
'log': log,
'timeout': opts.hasOwnProperty('timeout') ? opts.timeout : 2000
}, cb);
};
return (res);
}
function notify(rpcctx, channel, payload, options, callback) {
assert.object(rpcctx, 'rpcctx');
assert.string(channel, 'channel');
assert.string(payload, 'payload');
assert.object(options, 'options');
assert.optionalNumber(options.timeout, 'options.timeout');
assert.func(callback, 'callback');
var statement = 'select pg_notify($1, $2)';
var res = sql(rpcctx, statement, [channel, payload], options);
res.once('error', callback);
res.once('end', callback);
}
///--- Exports
module.exports = {
listen: listen,
notify: notify,
ping: ping,

@@ -195,0 +267,0 @@ sql: sql,

2

package.json
{
"name": "moray",
"description": "Moray client library",
"version": "3.7.0",
"version": "3.8.0",
"author": "Joyent (joyent.com)",

@@ -6,0 +6,0 @@ "keywords": [ "moray" ],

@@ -18,3 +18,3 @@ <!--

[Triton](https://github.com/joyent/triton) and
[Manta](http://github.com/joyent/manta) project pages. *Do not use GitHub PRs*.
[Manta](http://github.com/joyent/manta) project pages.

@@ -21,0 +21,0 @@

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