@sera4/essentia 1.1.34 → 1.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/package.tar.gz +0 -0
- package/paper-trail/index.js +1 -1
- package/queue/index.js +32 -0
- package/queue/publisher.js +13 -0
- package/queue/subscriber.js +13 -0
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|
package/paper-trail/index.js
CHANGED
|
@@ -33,7 +33,7 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
33
33
|
],
|
|
34
34
|
// additional fields to exclude on a global basis
|
|
35
35
|
excludeExtras: [],
|
|
36
|
-
censor: ["mfa_temp_secret", "mfa_secret"],
|
|
36
|
+
censor: ["password", "password_salt", "mfa_temp_secret", "mfa_secret"],
|
|
37
37
|
revisionAttribute: 'revision',
|
|
38
38
|
revisionModel: 'Revision',
|
|
39
39
|
revisionChangeModel: 'RevisionChange',
|
package/queue/index.js
CHANGED
|
@@ -192,6 +192,21 @@ class S4Queue {
|
|
|
192
192
|
this.pubs[name] = p;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Removes a previously registered publisher
|
|
197
|
+
* @param {String} exchange
|
|
198
|
+
*/
|
|
199
|
+
async unregisterPublisher(exchange) {
|
|
200
|
+
const name = exchange;
|
|
201
|
+
if (!Object.keys(this.pubs).includes(name)) {
|
|
202
|
+
throw new Error(`Publisher ${name} not registered`);
|
|
203
|
+
}
|
|
204
|
+
const p = this.pubs[name];
|
|
205
|
+
await p.closeChannel();
|
|
206
|
+
delete this.pubs[name];
|
|
207
|
+
logger.debug("Unregistered publisher", name);
|
|
208
|
+
}
|
|
209
|
+
|
|
195
210
|
/**
|
|
196
211
|
* Registers a new direct subscriber on a given exchange and queue.
|
|
197
212
|
* If exchange and queue don't exists, they'll be created
|
|
@@ -230,6 +245,23 @@ class S4Queue {
|
|
|
230
245
|
this.subs[name] = s;
|
|
231
246
|
}
|
|
232
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Removes a previously registered subscriber
|
|
250
|
+
* @param {String} exchange
|
|
251
|
+
* @param {String} queue the name of the queue.
|
|
252
|
+
* @param {String} key the name of the routing key.
|
|
253
|
+
*/
|
|
254
|
+
async unregisterSubscriber(exchange, queue, key) {
|
|
255
|
+
const name = `${exchange}-${queue}-${key}`;
|
|
256
|
+
if (!Object.keys(this.subs).includes(name)) {
|
|
257
|
+
throw new Error(`Subscriber ${name} not registered`);
|
|
258
|
+
}
|
|
259
|
+
const s = this.subs[name];
|
|
260
|
+
await s.closeChannel();
|
|
261
|
+
delete this.subs[name];
|
|
262
|
+
logger.debug("Unregistered subscriber", name);
|
|
263
|
+
}
|
|
264
|
+
|
|
233
265
|
/**
|
|
234
266
|
* Publishes a message on a given exchange with routing key.
|
|
235
267
|
* @param {String} exchange the name of the exchange.
|
package/queue/publisher.js
CHANGED
|
@@ -80,6 +80,19 @@ export class Publisher {
|
|
|
80
80
|
return parcel.tracking_id;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Closes the channel
|
|
85
|
+
* @returns promise
|
|
86
|
+
*/
|
|
87
|
+
async closeChannel() {
|
|
88
|
+
if (this.channel) {
|
|
89
|
+
logger.debug("Closing publishing channel", this.name);
|
|
90
|
+
return this.channel.close();
|
|
91
|
+
} else {
|
|
92
|
+
logger.error("Can't close a null publishing channel");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
83
96
|
async bindQueue(queue, pattern, args) {
|
|
84
97
|
await this.channel.bindQueue(queue, this.exchange, pattern, args)
|
|
85
98
|
}
|
package/queue/subscriber.js
CHANGED
|
@@ -82,6 +82,19 @@ export class Subscriber {
|
|
|
82
82
|
}, { noAck: false });
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Closes the channel
|
|
87
|
+
* @returns promise
|
|
88
|
+
*/
|
|
89
|
+
async closeChannel() {
|
|
90
|
+
if (this.channel) {
|
|
91
|
+
logger.debug("Closing subscriber channel", this.name);
|
|
92
|
+
return this.channel.close();
|
|
93
|
+
} else {
|
|
94
|
+
logger.error("Can't close a null subscriber channel");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
/**
|
|
86
99
|
* Register a new callback to recive message through this
|
|
87
100
|
* subscriber object
|