Comparing version 1.6.14 to 1.6.15
{ | ||
"name": "keuss", | ||
"version": "1.6.14", | ||
"version": "1.6.15", | ||
"keywords": [ | ||
@@ -37,3 +37,4 @@ "queue", | ||
"mongodb": "~4.5.0", | ||
"uuid": "~8.3.2" | ||
"uuid": "~8.3.2", | ||
"why-is-node-running": "^2.2.2" | ||
}, | ||
@@ -47,4 +48,4 @@ "devDependencies": { | ||
"test": "mocha --reporter spec --check-leaks --no-timeouts --exit test/", | ||
"test-with-coverage": "nyc --reporter=text -- mocha --reporter spec --check-leaks --no-timeouts --exit test/" | ||
"test-with-coverage": "nyc --reporter=html -- mocha --reporter spec --check-leaks --no-timeouts --exit test/" | ||
} | ||
} |
@@ -76,2 +76,8 @@ | ||
// to be extended: generic pubsub service | ||
subscribe_extra (topic, on_cb) {return false} | ||
unsubscribe_extra (subscr) {} | ||
emit_extra (topic, ev, cb) {if (cb) cb ();} | ||
static _hrtimeAsMSecs (hrtime) { | ||
@@ -78,0 +84,0 @@ return (hrtime[0] * 1000) + (hrtime[1] / 1e6); |
@@ -7,2 +7,3 @@ var mitt = require ('mitt'); | ||
////////////////////////////////////////////////////////////////////// | ||
class LocalSignal extends Signal { | ||
@@ -43,4 +44,10 @@ constructor (queue, factory, opts) { | ||
type () {return LocalSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
type () { | ||
return LocalSignalFactory.Type (); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emitInsertion (mature, cb) { | ||
@@ -51,2 +58,3 @@ debug ('got insertion event [%o], relay on local mitt', mature); | ||
////////////////////////////////////////////////////////////////////// | ||
emitPaused (paused, cb) { | ||
@@ -56,13 +64,44 @@ debug ('got paused event [%d], relay on local mitt', paused); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (topic, on_cb) { | ||
return this._factory.subscribe_extra (this._master.ns (), topic, on_cb); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (subscr) { | ||
this._factory.unsubscribe_extra (subscr); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (topic, ev, cb) { | ||
this._factory.emit_extra (this._master.ns (), topic, ev, cb); | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
class LocalSignalFactory { | ||
constructor (opts) { | ||
this._emitter = mitt(); | ||
debug ('created local factory'); | ||
} | ||
static Type () {return 'signal:local'} | ||
type () {return LocalSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
static Type () { | ||
return 'signal:local'; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
type () { | ||
return LocalSignalFactory.Type (); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
signal (queue, opts) { | ||
@@ -72,2 +111,35 @@ return new LocalSignal (queue, this, opts); | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (ns, topic, on_cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
debug ('subscribing to ns [%s], topic [%s]', ns, t); | ||
const s = { | ||
n: ns, | ||
t: t, | ||
f: (msg => on_cb (msg)) | ||
}; | ||
this._emitter.on (s.t, s.f); | ||
return s; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (s) { | ||
this._emitter.off (s.t, s.f); | ||
debug ('unsubscribed on %s', s.t); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (ns, topic, ev, cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
debug ('emit extra on topic [%s], value [%j]', t, ev); | ||
this._emitter.emit (t, ev); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
close (cb) { | ||
@@ -79,2 +151,3 @@ cb (); | ||
////////////////////////////////////////////////////////////////////// | ||
function creator (opts, cb) { | ||
@@ -81,0 +154,0 @@ return cb (null, new LocalSignalFactory (opts)); |
@@ -8,3 +8,3 @@ var mubsub = require('@nodebb/mubsub'); | ||
////////////////////////////////////////////////////////////////////// | ||
class MCSignal extends Signal { | ||
@@ -49,4 +49,8 @@ constructor (queue, factory, opts) { | ||
////////////////////////////////////////////////////////////////////// | ||
type () {return MCSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
emitInsertion (mature, cb) { | ||
@@ -57,2 +61,4 @@ debug ('emit insertion on topic [%s] value [%d])', this._topic_name, mature); | ||
////////////////////////////////////////////////////////////////////// | ||
emitPaused (paused, cb) { | ||
@@ -63,2 +69,4 @@ debug ('emit paused on topic [%s], value [%b]', this._topic_name, paused); | ||
////////////////////////////////////////////////////////////////////// | ||
_insertionEvent (mature) { | ||
@@ -68,4 +76,24 @@ debug ('got insertion event on ch [%s], mature is %s, calling master.emitInsertion()', this._channel, mature); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (topic, on_cb) { | ||
return this._factory.subscribe_extra (this._master.ns (), topic, on_cb); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (subscr) { | ||
this._factory.unsubscribe_extra (subscr); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (topic, ev, cb) { | ||
this._factory.emit_extra (this._master.ns (), topic, ev, cb); | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
class MCSignalFactory { | ||
@@ -87,5 +115,16 @@ constructor (opts) { | ||
static Type () {return 'signal:mongo-capped'} | ||
type () {return MCSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
static Type () { | ||
return 'signal:mongo-capped'; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
type () { | ||
return MCSignalFactory.Type (); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
signal (channel, opts) { | ||
@@ -95,2 +134,27 @@ return new MCSignal (channel, this, opts); | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (ns, topic, on_cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
debug ('subscribing to ns [%s], topic [%s]', ns, t); | ||
return this._channel.subscribe (t, on_cb); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (subscr) { | ||
subscr.unsubscribe (); | ||
debug ('unsubscribed on %j', subscr); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (ns, topic, ev, cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
debug ('emit extra on ns [%s], topic [%s], value [%j]', ns, t, ev); | ||
this._channel.publish (t, ev); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
close (cb) { | ||
@@ -102,2 +166,3 @@ this._mubsub.close (cb); | ||
////////////////////////////////////////////////////////////////////// | ||
function creator (opts, cb) { | ||
@@ -104,0 +169,0 @@ return cb (null, new MCSignalFactory (opts)); |
@@ -11,2 +11,3 @@ var mitt = require ('mitt'); | ||
////////////////////////////////////////////////////////////////////// | ||
class RPSSignal extends Signal { | ||
@@ -57,4 +58,10 @@ constructor (queue, factory, opts) { | ||
type () {return RPSSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
type () { | ||
return RPSSignalFactory.Type (); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emitInsertion (mature, cb) { | ||
@@ -65,2 +72,4 @@ debug ('emit insertion on channel [%s] value [%d])', this._channel, mature); | ||
////////////////////////////////////////////////////////////////////// | ||
emitPaused (paused, cb) { | ||
@@ -71,2 +80,4 @@ debug ('emit paused on channel [%s], value [%b]', this._channel, paused); | ||
////////////////////////////////////////////////////////////////////// | ||
_insertionEvent (mature) { | ||
@@ -76,4 +87,24 @@ debug ('got insertion event on ch [%s], mature is %s, calling master.emitInsertion()', this._channel, mature); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (topic, on_cb) { | ||
return this._factory.subscribe_extra (this._master.ns (), topic, on_cb); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (subscr) { | ||
this._factory.unsubscribe_extra (subscr); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (topic, ev, cb) { | ||
this._factory.emit_extra (this._master.ns (), topic, ev, cb); | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
class RPSSignalFactory { | ||
@@ -94,5 +125,16 @@ constructor (opts) { | ||
static Type () {return 'signal:redis-pubsub'} | ||
type () {return RPSSignalFactory.Type ()} | ||
////////////////////////////////////////////////////////////////////// | ||
static Type () { | ||
return 'signal:redis-pubsub'; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
type () { | ||
return RPSSignalFactory.Type (); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
signal (channel, opts) { | ||
@@ -103,2 +145,38 @@ debug ('creating redis-pubsub signaller with opts %o', opts); | ||
////////////////////////////////////////////////////////////////////// | ||
subscribe_extra (ns, topic, on_cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
debug ('subscribing to ns [%s], topic [%s]', ns, t); | ||
const s = { | ||
n: ns, | ||
t: t, | ||
f: (msg => on_cb (JSON.parse (msg))) | ||
}; | ||
this._emitter.on (s.t, s.f); | ||
this._rediscl_sub.subscribe (s.t); | ||
return s; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
unsubscribe_extra (subscr) { | ||
this._rediscl_sub.unsubscribe (subscr.t); | ||
this._emitter.off (subscr.t, subscr.f); | ||
debug ('unsubscribed on %j', subscr); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
emit_extra (ns, topic, ev, cb) { | ||
const t = `keuss:signal:${ns}:extra:${topic}`; | ||
const v = JSON.stringify(ev); | ||
debug ('emit extra on ns [%s], topic [%s], value [%j]', ns, t, ev); | ||
this._rediscl_pub.publish (t, v); | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
close (cb) { | ||
@@ -113,2 +191,3 @@ async.parallel ([ | ||
////////////////////////////////////////////////////////////////////// | ||
function creator (opts, cb) { | ||
@@ -115,0 +194,0 @@ return cb (null, new RPSSignalFactory (opts)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
389745
76
10535
10
+ Addedwhy-is-node-running@^2.2.2
+ Addedsiginfo@2.0.0(transitive)
+ Addedstackback@0.0.2(transitive)
+ Addedwhy-is-node-running@2.3.0(transitive)