'use strict';
const amqp = require('amqplib');
const { isFatalError: isFatalAMQPError } = require('amqplib/lib/connection');
-const common = require('./common');
+const { fileScope } = require('@squeep/log-helper');
-const _fileScope = common.fileScope(__filename);
+const _fileScope = fileScope(__filename);
/**
* Base class common to worker publisher and consumer, handling
*/
constructor(logger, options) {
this.logger = logger;
- this.options = Object.assign({
+ this.options = {
url: undefined,
name: 'messages',
prefix: 'squeep',
queueType: 'quorum',
retryDelayMs: 10000,
prefetch: 1,
- }, options);
- this.options.socketOptions = Object.assign({
+ ...options,
+ };
+ this.options.socketOptions = {
noDelay: undefined,
timeout: undefined,
keepAlive: undefined,
keepAliveDelay: undefined,
clientProperties: undefined,
- }, options.socketOptions);
+ ...options.socketOptions,
+ };
this.connection = undefined;
this.channel = undefined;
/**
- * Establish the necessary connections to the queue and lock services.
+ * Establish the necessary connections to the queue.
*/
async connect() {
const _scope = _fileScope('connect');
+++ /dev/null
-'use strict';
-const path = require('path');
-const { name: packageName, version: packageVersion } = require('../package');
-
-const libraryIdentifier = `${packageName}@${packageVersion}`;
-
-/**
- * Return a function for decorating logging method scopes.
- * @param {String} filename
- */
-const fileScope = (filename) => {
- const shortFilename = path.basename(filename, '.js');
- const fScope = (shortFilename === 'index') ? path.basename(path.dirname(filename)) : shortFilename;
- return (scope) => [libraryIdentifier, fScope, scope].join(':');
-};
-
-module.exports = {
- fileScope,
-};
\ No newline at end of file
'use strict';
const Base = require('./base');
-const common = require('./common');
+const { fileScope } = require('@squeep/log-helper');
-const _fileScope = common.fileScope(__filename);
+const _fileScope = fileScope(__filename);
class Consumer extends Base {
constructor(logger, options) {
'use strict';
const Base = require('./base');
-const common = require('./common');
+const { fileScope } = require('@squeep/log-helper');
-const _fileScope = common.fileScope(__filename);
+const _fileScope = fileScope(__filename);
class Publisher extends Base {
constructor(logger, options) {
}
const timestamp = (new Date()).getTime();
- options = Object.assign({ timestamp }, Publisher.publishDefaults, options);
+ options = {
+ timestamp,
+ ...Publisher.publishDefaults,
+ ...options,
+ };
return new Promise((resolve, reject) => {
if (!this.keepSending) {
"version": "1.0.0",
"license": "ISC",
"dependencies": {
+ "@squeep/log-helper": "^1.0.0",
"amqplib": "^0.10.3"
},
"devDependencies": {
"integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
"dev": true
},
+ "node_modules/@squeep/log-helper": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@squeep/log-helper/-/log-helper-1.0.0.tgz",
+ "integrity": "sha512-i61ECZLWQI2rhkXj9pDzH1Md5ICghL9zvh5QFVo0BTayuSrdS9SWkJ6gV1qWki/Xz6SuE0y0y145NyHlvOuVaw==",
+ "engines": {
+ "node": ">=14"
+ }
+ },
"node_modules/@squeep/test-helper": {
"version": "1.0.1",
"resolved": "git+https://git.squeep.com/squeep-test-helper#cc0f69b40de9ae3342f1b7a1784d37769e7f1e84",
"integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
"dev": true
},
+ "@squeep/log-helper": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@squeep/log-helper/-/log-helper-1.0.0.tgz",
+ "integrity": "sha512-i61ECZLWQI2rhkXj9pDzH1Md5ICghL9zvh5QFVo0BTayuSrdS9SWkJ6gV1qWki/Xz6SuE0y0y145NyHlvOuVaw=="
+ },
"@squeep/test-helper": {
"version": "git+https://git.squeep.com/squeep-test-helper#cc0f69b40de9ae3342f1b7a1784d37769e7f1e84",
"dev": true,
"eslint": "eslint *.js lib",
"test": "mocha --recursive"
},
- "author": "",
+ "author": "Justin Wind <jwind-npm@squeep.com>",
"license": "ISC",
"dependencies": {
+ "@squeep/log-helper": "^1.0.0",
"amqplib": "^0.10.3"
},
"devDependencies": {