Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-boss

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-boss - npm Package Compare versions

Comparing version 2.0.0-beta2 to 2.0.0-beta3

4

lib/attorney.js

@@ -28,4 +28,4 @@ 'use strict';

if (typeof config === 'string') {
config = { connectionString: config };
if (typeof config === 'string' || config.connectionString && typeof config.connectionString === 'string') {
config = { connectionString: config.connectionString || config };
} else {

@@ -32,0 +32,0 @@ assert(config.database && config.user && 'password' in config, 'configuration assert: not enough database settings to connect to PostgreSQL');

@@ -45,4 +45,2 @@ 'use strict';

value: function supervise() {
var _this2 = this;
var self = this;

@@ -52,18 +50,20 @@

return this.archive().then(function () {
if (_this2.config.monitorStateInterval) monitor(_this2.countStates, _this2.config.monitorStateInterval);
return Promise.join(monitor(this.archive, this.config.archiveCheckInterval), this.config.monitorStateInterval ? monitor(this.countStates, this.config.monitorStateInterval) : null);
monitor(_this2.archive, _this2.config.archiveCheckInterval);
});
function monitor(func, interval) {
if (self.stopped) return;
self.timers[func.name] = setTimeout(function () {
func.call(self).catch(function (error) {
return exec().then(repeat);
function exec() {
return func.call(self).catch(function (error) {
return self.emit(events.error, error);
}).then(function () {
return monitor(func, interval);
});
}, interval);
}
function repeat() {
if (self.stopped) return;
self.timers[func.name] = setTimeout(function () {
return exec().then(repeat);
}, interval);
}
}

@@ -74,6 +74,11 @@ }

value: function countStates() {
var _this3 = this;
var _this2 = this;
return this.db.executeSql(this.countStatesCommand).then(function (result) {
return _this3.emit(events.monitorStates, result.rows[0]);
var states = result.rows[0];
// parsing int64 since pg returns it as string
Object.keys(states).forEach(function (state) {
return states[state] = parseFloat(states[state]);
});
_this2.emit(events.monitorStates, states);
});

@@ -84,6 +89,6 @@ }

value: function archive() {
var _this4 = this;
var _this3 = this;
return this.db.executeSql(this.archiveCommand, this.config.archiveCompletedJobsEvery).then(function (result) {
if (result.rowCount) _this4.emit(events.archived, result.rowCount);
if (result.rowCount) _this3.emit(events.archived, result.rowCount);
});

@@ -94,3 +99,3 @@ }

value: function stop() {
var _this5 = this;
var _this4 = this;

@@ -100,3 +105,3 @@ this.stopped = true;

Object.keys(this.timers).forEach(function (key) {
return clearTimeout(_this5.timers[key]);
return clearTimeout(_this4.timers[key]);
});

@@ -103,0 +108,0 @@

@@ -37,2 +37,3 @@ 'use strict';

max: poolConfig.poolSize,
ssl: !!poolConfig.ssl,
Promise: Promise

@@ -61,2 +62,7 @@ });

_createClass(Db, [{
key: 'close',
value: function close() {
return this.pool.end();
}
}, {
key: 'executeSql',

@@ -63,0 +69,0 @@ value: function executeSql(text, values) {

@@ -22,2 +22,3 @@ 'use strict';

var startInProgressErrorMessage = 'boss is starting up. Please wait for the previous start() to finish.';
var notStartedErrorMessage = 'boss ain\'t started. Use start().';

@@ -46,4 +47,2 @@ var PgBoss = function (_EventEmitter) {

_this.config = config;
var db = new Db(config);

@@ -53,4 +52,2 @@

_this.contractor = new Contractor(db, config);
var boss = new Boss(db, config);

@@ -60,3 +57,2 @@ boss.promotedEvents.forEach(function (event) {

});
_this.boss = boss;

@@ -67,3 +63,2 @@ var manager = new Manager(db, config);

});
_this.manager = manager;

@@ -74,2 +69,8 @@ ['fetch', 'complete', 'cancel', 'fail', 'publish', 'subscribe', 'unsubscribe', 'onComplete', 'onExpire'].forEach(function (func) {

_this.config = config;
_this.db = db;
_this.boss = boss;
_this.contractor = new Contractor(db, config);
_this.manager = manager;
function promoteApi(obj, func) {

@@ -106,6 +107,5 @@ var _this2 = this;

return this.boss.supervise().then(function () {
return _this4.manager.monitor();
}).then(function () {
return Promise.join(this.boss.supervise(), this.manager.monitor()).then(function () {
_this4.isReady = true;
_this4.isStarted = true;
return _this4;

@@ -117,3 +117,3 @@ });

value: function start() {
var self = this;
var _this5 = this;

@@ -128,5 +128,7 @@ if (this.isStarting) return Promise.reject(startInProgressErrorMessage);

return this.contractor.start.apply(this.contractor, args).then(function () {
self.isStarting = false;
return self.init();
var check = this.isStarted ? Promise.resolve(true) : this.contractor.start.apply(this.contractor, args);
return check.then(function () {
_this5.isStarting = false;
return _this5.init();
});

@@ -137,3 +139,12 @@ }

value: function stop() {
return Promise.all([this.disconnect(), this.manager.stop(), this.boss.stop()]);
var _this6 = this;
if (!this.isStarted) return Promise.reject(notStartedErrorMessage);
return Promise.join(this.manager.stop(), this.boss.stop()).then(function () {
return _this6.db.close();
}).then(function () {
_this6.isReady = false;
_this6.isStarted = false;
});
}

@@ -143,3 +154,3 @@ }, {

value: function connect() {
var self = this;
var _this7 = this;

@@ -151,4 +162,4 @@ for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {

return this.contractor.connect.apply(this.contractor, args).then(function () {
self.isReady = true;
return self;
_this7.isReady = true;
return _this7;
});

@@ -159,3 +170,3 @@ }

value: function disconnect() {
var _this5 = this;
var _this8 = this;

@@ -169,3 +180,5 @@ if (!this.isReady) return Promise.reject(notReadyErrorMessage);

return this.manager.close.apply(this.manager, args).then(function () {
return _this5.isReady = false;
return _this8.db.close();
}).then(function () {
return _this8.isReady = false;
});

@@ -172,0 +185,0 @@ }

{
"name": "pg-boss",
"version": "2.0.0-beta2",
"version": "2.0.0-beta3",
"description": "Queueing jobs in Node.js using PostgreSQL like a boss",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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