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

@bull-monitor/root

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bull-monitor/root - npm Package Compare versions

Comparing version 3.0.0-alpha.0 to 3.0.0-alpha.1

14

CHANGELOG.md

@@ -6,2 +6,16 @@ # Change Log

# [3.0.0-alpha.1](https://github.com/s-r-x/bull-monitor/compare/v3.0.0-alpha.0...v3.0.0-alpha.1) (2022-01-10)
* feat!: compile to es2018 ([ac96e15](https://github.com/s-r-x/bull-monitor/commit/ac96e152967f8ff2c7f28030c92ea5ecaaa46cd3))
### BREAKING CHANGES
* drop support for node<10
# [3.0.0-alpha.0](https://github.com/s-r-x/bull-monitor/compare/v2.16.0...v3.0.0-alpha.0) (2022-01-10)

@@ -8,0 +22,0 @@

189

dist/bull-adapter.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -59,46 +50,28 @@ exports.BullAdapter = exports.BullJobAdapter = void 0;

}
getState() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.getState();
});
async getState() {
return this._job.getState();
}
moveToCompleted(returnValue) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.moveToCompleted(returnValue);
});
async moveToCompleted(returnValue) {
return this._job.moveToCompleted(returnValue);
}
moveToFailed(reason) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.moveToFailed(reason);
});
async moveToFailed(reason) {
return this._job.moveToFailed(reason);
}
promote() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.promote();
});
async promote() {
return this._job.promote();
}
discard() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.discard();
});
async discard() {
return this._job.discard();
}
update(data) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.update(data);
});
async update(data) {
return this._job.update(data);
}
retry() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.retry();
});
async retry() {
return this._job.retry();
}
remove() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.remove();
});
async remove() {
return this._job.remove();
}
log(row) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.log(row);
});
async log(row) {
return this._job.log(row);
}

@@ -144,102 +117,64 @@ }

}
count() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.count();
});
async count() {
return this._queue.count();
}
add(name, data, opts) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this._queue.add(name, data, opts);
return this.normalizeJob(job);
});
async add(name, data, opts) {
const job = await this._queue.add(name, data, opts);
return this.normalizeJob(job);
}
pause(isLocal, doNotWaitActive) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.pause(isLocal, doNotWaitActive);
});
async pause(isLocal, doNotWaitActive) {
return this._queue.pause(isLocal, doNotWaitActive);
}
resume(isLocal) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.resume(isLocal);
});
async resume(isLocal) {
return this._queue.resume(isLocal);
}
clean(grace, status, limit) {
return __awaiter(this, void 0, void 0, function* () {
const jobs = yield this._queue.clean(grace, status, limit);
return jobs.map((job) => String(job.id));
});
async clean(grace, status, limit) {
const jobs = await this._queue.clean(grace, status, limit);
return jobs.map((job) => String(job.id));
}
empty() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.empty();
});
async empty() {
return this._queue.empty();
}
isPaused() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.isPaused();
});
async isPaused() {
return this._queue.isPaused();
}
getJob(id) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this._queue.getJob(id);
if (job) {
return this.normalizeJob(job);
}
});
async getJob(id) {
const job = await this._queue.getJob(id);
if (job) {
return this.normalizeJob(job);
}
}
getJobs(status, start, end, asc) {
return __awaiter(this, void 0, void 0, function* () {
const jobs = yield this._queue.getJobs([status], start, end, asc);
return jobs.map((job) => this.normalizeJob(job));
});
async getJobs(status, start, end, asc) {
const jobs = await this._queue.getJobs([status], start, end, asc);
return jobs.map((job) => this.normalizeJob(job));
}
getJobCounts() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getJobCounts();
});
async getJobCounts() {
return this._queue.getJobCounts();
}
getActiveCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getActiveCount();
});
async getActiveCount() {
return this._queue.getActiveCount();
}
getCompletedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getCompletedCount();
});
async getCompletedCount() {
return this._queue.getCompletedCount();
}
getFailedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getFailedCount();
});
async getFailedCount() {
return this._queue.getFailedCount();
}
getDelayedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getDelayedCount();
});
async getDelayedCount() {
return this._queue.getDelayedCount();
}
getWaitingCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getWaitingCount();
});
async getWaitingCount() {
return this._queue.getWaitingCount();
}
getPausedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getPausedCount();
});
async getPausedCount() {
return this._queue.getPausedCount();
}
removeJobs(pattern) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.removeJobs(pattern);
});
async removeJobs(pattern) {
return this._queue.removeJobs(pattern);
}
getJobLogs(jobId) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getJobLogs(jobId);
});
async getJobLogs(jobId) {
return this._queue.getJobLogs(jobId);
}
close(doNotWaitJobs) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.close(doNotWaitJobs);
});
async close(doNotWaitJobs) {
return this._queue.close(doNotWaitJobs);
}

@@ -246,0 +181,0 @@ // private methods

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -65,47 +56,29 @@ exports.BullMQAdapter = exports.BullMQJobAdapter = void 0;

}
getState() {
return __awaiter(this, void 0, void 0, function* () {
const status = yield this._job.getState();
return status;
});
async getState() {
const status = await this._job.getState();
return status;
}
moveToCompleted(returnValue) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.moveToCompleted(returnValue, this._queue.token);
});
async moveToCompleted(returnValue) {
return this._job.moveToCompleted(returnValue, this._queue.token);
}
moveToFailed(reason) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.moveToFailed(reason, this._queue.token);
});
async moveToFailed(reason) {
return this._job.moveToFailed(reason, this._queue.token);
}
promote() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.promote();
});
async promote() {
return this._job.promote();
}
discard() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.discard();
});
async discard() {
return this._job.discard();
}
update(data) {
return __awaiter(this, void 0, void 0, function* () {
return this._job.update(data);
});
async update(data) {
return this._job.update(data);
}
retry() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.retry();
});
async retry() {
return this._job.retry();
}
remove() {
return __awaiter(this, void 0, void 0, function* () {
return this._job.remove();
});
async remove() {
return this._job.remove();
}
log(row) {
return __awaiter(this, void 0, void 0, function* () {
yield this._job.log(row);
});
async log(row) {
await this._job.log(row);
}

@@ -164,105 +137,67 @@ }

}
count() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.count();
});
async count() {
return this._queue.count();
}
add(name, data, opts) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this._queue.add(name, data, opts);
return this.normalizeJob(job);
});
async add(name, data, opts) {
const job = await this._queue.add(name, data, opts);
return this.normalizeJob(job);
}
pause() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.pause();
});
async pause() {
return this._queue.pause();
}
resume() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.resume();
});
async resume() {
return this._queue.resume();
}
clean(grace, status, limit = Number.MAX_SAFE_INTEGER) {
return __awaiter(this, void 0, void 0, function* () {
return yield this._queue.clean(grace, limit, status);
});
async clean(grace, status, limit = Number.MAX_SAFE_INTEGER) {
return await this._queue.clean(grace, limit, status);
}
empty() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.drain();
});
async empty() {
return this._queue.drain();
}
isPaused() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.isPaused();
});
async isPaused() {
return this._queue.isPaused();
}
getJob(id) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this._queue.getJob(id);
if (job) {
return this.normalizeJob(job);
}
});
async getJob(id) {
const job = await this._queue.getJob(id);
if (job) {
return this.normalizeJob(job);
}
}
getJobs(types, start, end, asc) {
return __awaiter(this, void 0, void 0, function* () {
const jobs = yield this._queue.getJobs(types, start, end, asc);
return jobs.map((job) => this.normalizeJob(job));
});
async getJobs(types, start, end, asc) {
const jobs = await this._queue.getJobs(types, start, end, asc);
return jobs.map((job) => this.normalizeJob(job));
}
getJobCounts() {
return __awaiter(this, void 0, void 0, function* () {
const counts = yield this._queue.getJobCounts('active', 'completed', 'failed', 'delayed', 'waiting', 'paused');
return counts;
});
async getJobCounts() {
const counts = await this._queue.getJobCounts('active', 'completed', 'failed', 'delayed', 'waiting', 'paused');
return counts;
}
getActiveCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getActiveCount();
});
async getActiveCount() {
return this._queue.getActiveCount();
}
getCompletedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getCompletedCount();
});
async getCompletedCount() {
return this._queue.getCompletedCount();
}
getFailedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getFailedCount();
});
async getFailedCount() {
return this._queue.getFailedCount();
}
getDelayedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getDelayedCount();
});
async getDelayedCount() {
return this._queue.getDelayedCount();
}
getWaitingCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getWaitingCount();
});
async getWaitingCount() {
return this._queue.getWaitingCount();
}
getPausedCount() {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getJobCountByTypes('paused');
});
async getPausedCount() {
return this._queue.getJobCountByTypes('paused');
}
removeJobs() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Not implemented');
});
async removeJobs() {
throw new Error('Not implemented');
}
getJobLogs(jobId) {
return __awaiter(this, void 0, void 0, function* () {
return this._queue.getJobLogs(jobId);
});
async getJobLogs(jobId) {
return this._queue.getJobLogs(jobId);
}
close() {
return __awaiter(this, void 0, void 0, function* () {
yield this._queue.close();
if (this._queueEvents) {
yield this._queueEvents.close();
}
});
async close() {
await this._queue.close();
if (this._queueEvents) {
await this._queueEvents.close();
}
}

@@ -269,0 +204,0 @@ // private methods

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -43,44 +15,31 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

}
search(args) {
var e_1, _a;
return __awaiter(this, void 0, void 0, function* () {
let expr;
try {
expr = (0, jsonata_1.default)(args.search);
}
catch (_e) {
return [];
}
const it = this._getIterator(args);
if (!it)
return [];
const start = args.offset;
const end = args.limit + start;
const acc = [];
try {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
mainLoop: for (var _b = __asyncValues(it.generator()), _c; _c = yield _b.next(), !_c.done;) {
const jobs = _c.value;
for (const job of jobs) {
const matched = this._matchData(job.data, expr);
if (matched) {
acc.push(job.id);
}
if (acc.length >= end) {
break mainLoop;
}
}
async search(args) {
let expr;
try {
expr = (0, jsonata_1.default)(args.search);
}
catch (_e) {
return [];
}
const it = this._getIterator(args);
if (!it)
return [];
const start = args.offset;
const end = args.limit + start;
const acc = [];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
mainLoop: for await (const jobs of it.generator()) {
for (const job of jobs) {
const matched = this._matchData(job.data, expr);
if (matched) {
acc.push(job.id);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
if (acc.length >= end) {
break mainLoop;
}
finally { if (e_1) throw e_1.error; }
}
it.destroy();
const jobs = yield Promise.all(acc.slice(start, end).map((id) => this._queue.getJob(id)));
return jobs;
});
}
it.destroy();
const jobs = await Promise.all(acc.slice(start, end).map((id) => this._queue.getJob(id)));
return jobs;
}

@@ -121,18 +80,16 @@ _getIterator(args) {

}
_extractJobsData(ids) {
return __awaiter(this, void 0, void 0, function* () {
const client = yield this._queue.client;
const pipeline = client.pipeline();
ids.forEach((id) => pipeline.hmget(this._queue.toKey(id), 'data'));
const data = yield pipeline.exec();
return data.reduce((acc, [error, [jobData]], idx) => {
if (!error && jobData && jobData !== '{}' && jobData !== '[]') {
acc.push({
data: jobData,
id: ids[idx],
});
}
return acc;
}, []);
});
async _extractJobsData(ids) {
const client = await this._queue.client;
const pipeline = client.pipeline();
ids.forEach((id) => pipeline.hmget(this._queue.toKey(id), 'data'));
const data = await pipeline.exec();
return data.reduce((acc, [error, [jobData]], idx) => {
if (!error && jobData && jobData !== '{}' && jobData !== '[]') {
acc.push({
data: jobData,
id: ids[idx],
});
}
return acc;
}, []);
}

@@ -145,27 +102,14 @@ }

}
generator() {
return __asyncGenerator(this, arguments, function* generator_1() {
var e_2, _a;
const client = yield __await(this._queue.client);
this._stream = client.zscanStream(this._key, {
count: this._scanCount,
});
try {
for (var _b = __asyncValues(this._stream), _c; _c = yield __await(_b.next()), !_c.done;) {
const ids = _c.value;
this._stream.pause();
const filteredIds = ids.filter((_k, idx) => !(idx % 2));
const data = yield __await(this._extractJobsData(filteredIds));
yield yield __await(data);
this._stream.resume();
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_2) throw e_2.error; }
}
async *generator() {
const client = await this._queue.client;
this._stream = client.zscanStream(this._key, {
count: this._scanCount,
});
for await (const ids of this._stream) {
this._stream.pause();
const filteredIds = ids.filter((_k, idx) => !(idx % 2));
const data = await this._extractJobsData(filteredIds);
yield data;
this._stream.resume();
}
}

@@ -184,22 +128,20 @@ destroy() {

}
generator() {
return __asyncGenerator(this, arguments, function* generator_2() {
const client = yield __await(this._queue.client);
this._ids = yield __await(client.lrange(this._key, 0, -1));
while (true) {
try {
const ids = this._nextChunk;
if ((0, isEmpty_1.default)(ids)) {
return yield __await(void 0);
}
const data = yield __await(this._extractJobsData(ids));
this._incCursor(data.length);
yield yield __await(data);
async *generator() {
const client = await this._queue.client;
this._ids = await client.lrange(this._key, 0, -1);
while (true) {
try {
const ids = this._nextChunk;
if ((0, isEmpty_1.default)(ids)) {
return;
}
catch (e) {
console.error(e);
return yield __await(void 0);
}
const data = await this._extractJobsData(ids);
this._incCursor(data.length);
yield data;
}
});
catch (e) {
console.error(e);
return;
}
}
}

@@ -206,0 +148,0 @@ // noop

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -42,54 +33,50 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

}
getQueueJobs({ queue, limit = 20, offset = 0, status, id, ids, order = gql_1.OrderEnum.Desc, dataSearch, }) {
return __awaiter(this, void 0, void 0, function* () {
if (!(0, isNil_1.default)(offset) && offset < 0) {
this._throwInternalError(errors_enum_1.BullErrorEnum.BAD_OFFSET);
}
if (!(0, isNil_1.default)(limit) && limit < 1) {
this._throwInternalError(errors_enum_1.BullErrorEnum.BAD_LIMIT);
}
const bullQueue = this.getQueueById(queue, true);
if (ids) {
return yield Promise.all(ids.map((id) => bullQueue.getJob(id))).then(this._filterJobs);
}
else if (id) {
const job = yield bullQueue.getJob(id);
return job ? [job] : [];
}
else if (dataSearch) {
if (status) {
const searcher = new data_search_1.DataSearcher(bullQueue);
return yield searcher
.search({
status,
search: dataSearch,
offset: offset,
limit: limit,
scanCount: this._config.textSearchScanCount,
})
.then(this._filterJobs);
}
else {
this._throwInternalError(errors_enum_1.BullErrorEnum.DATA_SEARCH_STATUS_REQUIRED);
}
}
else if (status) {
return yield bullQueue
.getJobs([status], offset, offset + limit - 1, order === gql_1.OrderEnum.Asc)
async getQueueJobs({ queue, limit = 20, offset = 0, status, id, ids, order = gql_1.OrderEnum.Desc, dataSearch, }) {
if (!(0, isNil_1.default)(offset) && offset < 0) {
this._throwInternalError(errors_enum_1.BullErrorEnum.BAD_OFFSET);
}
if (!(0, isNil_1.default)(limit) && limit < 1) {
this._throwInternalError(errors_enum_1.BullErrorEnum.BAD_LIMIT);
}
const bullQueue = this.getQueueById(queue, true);
if (ids) {
return await Promise.all(ids.map((id) => bullQueue.getJob(id))).then(this._filterJobs);
}
else if (id) {
const job = await bullQueue.getJob(id);
return job ? [job] : [];
}
else if (dataSearch) {
if (status) {
const searcher = new data_search_1.DataSearcher(bullQueue);
return await searcher
.search({
status,
search: dataSearch,
offset: offset,
limit: limit,
scanCount: this._config.textSearchScanCount,
})
.then(this._filterJobs);
}
{
return [];
else {
this._throwInternalError(errors_enum_1.BullErrorEnum.DATA_SEARCH_STATUS_REQUIRED);
}
});
}
else if (status) {
return await bullQueue
.getJobs([status], offset, offset + limit - 1, order === gql_1.OrderEnum.Asc)
.then(this._filterJobs);
}
{
return [];
}
}
getJob(queueId, id, throwIfNotFound) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(queueId, true);
const job = yield queue.getJob(id);
if (!job && throwIfNotFound) {
this._throwJobNotFound();
}
return job;
});
async getJob(queueId, id, throwIfNotFound) {
const queue = this.getQueueById(queueId, true);
const job = await queue.getJob(id);
if (!job && throwIfNotFound) {
this._throwJobNotFound();
}
return job;
}

@@ -101,180 +88,128 @@ extractJobProcessingTime(job) {

}
getQueueJobsCounts(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getJobCounts());
});
async getQueueJobsCounts(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getJobCounts());
}
getQueueFailedCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getFailedCount());
});
async getQueueFailedCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getFailedCount());
}
getQueueCompletedCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getCompletedCount());
});
async getQueueCompletedCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getCompletedCount());
}
getQueueDelayedCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getDelayedCount());
});
async getQueueDelayedCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getDelayedCount());
}
getQueueActiveCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getActiveCount());
});
async getQueueActiveCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getActiveCount());
}
getQueueWaitingCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getWaitingCount());
});
async getQueueWaitingCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getWaitingCount());
}
getQueuePausedCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.getPausedCount());
});
async getQueuePausedCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.getPausedCount());
}
getQueueWaitingOrDelayedJobsCount(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id);
return yield (queue === null || queue === void 0 ? void 0 : queue.count());
});
async getQueueWaitingOrDelayedJobsCount(id) {
const queue = this.getQueueById(id);
return await (queue === null || queue === void 0 ? void 0 : queue.count());
}
getRedisInfo() {
return __awaiter(this, void 0, void 0, function* () {
if (this._queuesMap.size > 0) {
const firstQueue = this._queues[0];
const client = yield firstQueue.client;
const rawInfo = yield client.info();
return redis_info_1.default.parse(rawInfo);
}
return null;
});
async getRedisInfo() {
if (this._queuesMap.size > 0) {
const firstQueue = this._queues[0];
const client = await firstQueue.client;
const rawInfo = await client.info();
return redis_info_1.default.parse(rawInfo);
}
return null;
}
// mutations
createJob({ queue: queueId, name = null, data = {}, options = {}, }) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(queueId, true);
return yield queue.add(name, json_1.JsonService.maybeParse(data), json_1.JsonService.maybeParse(options));
});
async createJob({ queue: queueId, name = null, data = {}, options = {}, }) {
const queue = this.getQueueById(queueId, true);
return await queue.add(name, json_1.JsonService.maybeParse(data), json_1.JsonService.maybeParse(options));
}
removeJobsByPattern(args) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(args.queue, true);
yield queue.removeJobs(args.pattern);
return true;
});
async removeJobsByPattern(args) {
const queue = this.getQueueById(args.queue, true);
await queue.removeJobs(args.pattern);
return true;
}
pauseQueue(id) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(id, true);
yield queue.pause();
return queue;
});
async pauseQueue(id) {
const queue = this.getQueueById(id, true);
await queue.pause();
return queue;
}
cleanQueue(args) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(args.queue, true);
return yield queue.clean(args.grace, args.status, args.limit || undefined);
});
async cleanQueue(args) {
const queue = this.getQueueById(args.queue, true);
return await queue.clean(args.grace, args.status, args.limit || undefined);
}
emptyQueue(args) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(args.queue, true);
yield queue.empty();
return queue;
});
async emptyQueue(args) {
const queue = this.getQueueById(args.queue, true);
await queue.empty();
return queue;
}
closeQueue(args) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(args.queue, true);
yield queue.close();
return queue;
});
async closeQueue(args) {
const queue = this.getQueueById(args.queue, true);
await queue.close();
return queue;
}
resumeQueue(args) {
return __awaiter(this, void 0, void 0, function* () {
const queue = this.getQueueById(args.queue, true);
yield queue.resume();
return queue;
});
async resumeQueue(args) {
const queue = this.getQueueById(args.queue, true);
await queue.resume();
return queue;
}
promoteJob(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.promote());
return job;
});
async promoteJob(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.promote());
return job;
}
discardJob(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.discard());
return job;
});
async discardJob(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.discard());
return job;
}
updateJobData(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.update(json_1.JsonService.maybeParse(args.data)));
return job;
});
async updateJobData(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.update(json_1.JsonService.maybeParse(args.data)));
return job;
}
createJobLog(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.log(args.row));
return job;
});
async createJobLog(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.log(args.row));
return job;
}
retryJob(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.retry());
return job;
});
async retryJob(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.retry());
return job;
}
retryJobs(args) {
return __awaiter(this, void 0, void 0, function* () {
const jobs = yield Promise.all(args.jobs.map((jobId) => this.getJob(args.queue, jobId, true)));
yield Promise.all(jobs.map((job) => job === null || job === void 0 ? void 0 : job.retry()));
return jobs;
});
async retryJobs(args) {
const jobs = await Promise.all(args.jobs.map((jobId) => this.getJob(args.queue, jobId, true)));
await Promise.all(jobs.map((job) => job === null || job === void 0 ? void 0 : job.retry()));
return jobs;
}
removeJobById(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.remove());
return job;
});
async removeJobById(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.remove());
return job;
}
removeJobs(args) {
return __awaiter(this, void 0, void 0, function* () {
const jobs = yield Promise.all(args.jobs.map((jobId) => this.getJob(args.queue, jobId, true)));
yield Promise.all(jobs.map((job) => job === null || job === void 0 ? void 0 : job.remove()));
return jobs;
});
async removeJobs(args) {
const jobs = await Promise.all(args.jobs.map((jobId) => this.getJob(args.queue, jobId, true)));
await Promise.all(jobs.map((job) => job === null || job === void 0 ? void 0 : job.remove()));
return jobs;
}
moveJobToCompleted(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.moveToCompleted());
return job;
});
async moveJobToCompleted(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.moveToCompleted());
return job;
}
moveJobToFailed(args) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield this.getJob(args.queue, args.id, true);
yield (job === null || job === void 0 ? void 0 : job.moveToFailed({
message: '',
}));
return job;
});
async moveJobToFailed(args) {
const job = await this.getJob(args.queue, args.id, true);
await (job === null || job === void 0 ? void 0 : job.moveToFailed({
message: '',
}));
return job;
}

@@ -281,0 +216,0 @@ _filterJobs(jobs) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,18 +12,12 @@ exports.MetricsDataSource = void 0;

}
getMetrics(queue, start, end) {
return __awaiter(this, void 0, void 0, function* () {
return yield this._collector.extract(queue, start, end);
});
async getMetrics(queue, start, end) {
return await this._collector.extract(queue, start, end);
}
clearAllMetrics() {
return __awaiter(this, void 0, void 0, function* () {
yield this._collector.clearAll();
return true;
});
async clearAllMetrics() {
await this._collector.clearAll();
return true;
}
clearMetrics(queue) {
return __awaiter(this, void 0, void 0, function* () {
yield this._collector.clear(queue);
return true;
});
async clearMetrics(queue) {
await this._collector.clear(queue);
return true;
}

@@ -39,0 +24,0 @@ _throwInternalError(e) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,37 +6,25 @@ exports.mutationResolver = void 0;

Mutation: {
createJob(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.input.queue);
return yield bull.createJob(args.input);
});
async createJob(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.input.queue);
return await bull.createJob(args.input);
},
pauseQueue(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield bull.pauseQueue(args.queue);
});
async pauseQueue(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await bull.pauseQueue(args.queue);
},
resumeQueue(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield bull.resumeQueue(args);
});
async resumeQueue(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await bull.resumeQueue(args);
},
cleanQueue(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield bull.cleanQueue(args);
});
async cleanQueue(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await bull.cleanQueue(args);
},
emptyQueue(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield bull.emptyQueue(args);
});
async emptyQueue(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await bull.emptyQueue(args);
},
closeQueue(_, args, { dataSources: { bull, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield bull.closeQueue(args);
});
async closeQueue(_, args, { dataSources: { bull, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await bull.closeQueue(args);
},

@@ -96,12 +75,8 @@ moveJobToCompleted(_, args, { dataSources: { bull, policies } }) {

},
clearMetrics(_, args, { dataSources: { metrics, policies } }) {
return __awaiter(this, void 0, void 0, function* () {
policies.raiseIfQueueReadonly(args.queue);
return yield metrics.clearMetrics(args.queue);
});
async clearMetrics(_, args, { dataSources: { metrics, policies } }) {
policies.raiseIfQueueReadonly(args.queue);
return await metrics.clearMetrics(args.queue);
},
clearAllMetrics(_, __, { dataSources: { metrics } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield metrics.clearAllMetrics();
});
async clearAllMetrics(_, __, { dataSources: { metrics } }) {
return await metrics.clearAllMetrics();
},

@@ -108,0 +83,0 @@ },

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,11 +6,7 @@ exports.queryResolver = void 0;

Query: {
redisInfo(_, __, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getRedisInfo();
});
async redisInfo(_, __, { dataSources: { bull } }) {
return await bull.getRedisInfo();
},
metrics(_, args, { dataSources: { metrics } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield metrics.getMetrics(args.queue, args.start, args.end);
});
async metrics(_, args, { dataSources: { metrics } }) {
return await metrics.getMetrics(args.queue, args.start, args.end);
},

@@ -32,11 +19,7 @@ queues(_, __, { dataSources: { bull } }) {

},
jobs(_, args, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueJobs(args);
});
async jobs(_, args, { dataSources: { bull } }) {
return await bull.getQueueJobs(args);
},
job(_parent, { queue, id }, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getJob(queue, id);
});
async job(_parent, { queue, id }, { dataSources: { bull } }) {
return await bull.getJob(queue, id);
},

@@ -43,0 +26,0 @@ },

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,63 +6,39 @@ exports.queueResolver = void 0;

Queue: {
count(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueWaitingOrDelayedJobsCount(parent.id);
});
async count(parent, _, { dataSources: { bull } }) {
return await bull.getQueueWaitingOrDelayedJobsCount(parent.id);
},
readonly(parent, _, { dataSources: { policies } }) {
return __awaiter(this, void 0, void 0, function* () {
return policies.isQueueReadonly(parent.id);
});
async readonly(parent, _, { dataSources: { policies } }) {
return policies.isQueueReadonly(parent.id);
},
failedCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueFailedCount(parent.id);
});
async failedCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueFailedCount(parent.id);
},
completedCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueCompletedCount(parent.id);
});
async completedCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueCompletedCount(parent.id);
},
delayedCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueDelayedCount(parent.id);
});
async delayedCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueDelayedCount(parent.id);
},
activeCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueActiveCount(parent.id);
});
async activeCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueActiveCount(parent.id);
},
waitingCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueWaitingCount(parent.id);
});
async waitingCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueWaitingCount(parent.id);
},
pausedCount(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueWaitingCount(parent.id);
});
async pausedCount(parent, _, { dataSources: { bull } }) {
return await bull.getQueueWaitingCount(parent.id);
},
jobsCounts(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueJobsCounts(parent.id);
});
async jobsCounts(parent, _, { dataSources: { bull } }) {
return await bull.getQueueJobsCounts(parent.id);
},
isPaused(parent) {
return __awaiter(this, void 0, void 0, function* () {
return yield parent.isPaused();
});
async isPaused(parent) {
return await parent.isPaused();
},
jobs(parent, _, { dataSources: { bull } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield bull.getQueueJobs({
queue: parent.id,
});
async jobs(parent, _, { dataSources: { bull } }) {
return await bull.getQueueJobs({
queue: parent.id,
});
},
metrics(parent, _, { dataSources: { metrics } }) {
return __awaiter(this, void 0, void 0, function* () {
return yield metrics.getMetrics(parent.id);
});
async metrics(parent, _, { dataSources: { metrics } }) {
return await metrics.getMetrics(parent.id);
},

@@ -78,0 +45,0 @@ },

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -57,6 +48,4 @@ exports.BullMonitor = void 0;

}
startServer() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.server.start();
});
async startServer() {
return await this.server.start();
}

@@ -108,4 +97,9 @@ renderUi() {

_normalizeConfig(config) {
return Object.assign(Object.assign(Object.assign({}, constants_1.DEFAULT_ROOT_CONFIG), config), { metrics: config.metrics
? Object.assign(Object.assign({}, constants_1.DEFAULT_METRICS_CONFIG), config.metrics) : false });
return {
...constants_1.DEFAULT_ROOT_CONFIG,
...config,
metrics: config.metrics
? { ...constants_1.DEFAULT_METRICS_CONFIG, ...config.metrics }
: false,
};
}

@@ -112,0 +106,0 @@ _initMetricsCollector() {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -26,6 +17,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

this._isActive = false;
this._taskFn = () => __awaiter(this, void 0, void 0, function* () {
const metrics = yield this._collect();
yield this._persist(metrics);
});
this._taskFn = async () => {
const metrics = await this._collect();
await this._persist(metrics);
};
this._scheduler = new toad_scheduler_1.ToadScheduler();

@@ -45,25 +36,19 @@ this._queues = queues.filter((q) => !_config.blacklist.includes(q.name));

}
extract(queue, start = 0, end = -1) {
return __awaiter(this, void 0, void 0, function* () {
const key = this._buildPersistKey(queue);
const client = yield this._redisClient;
const metrics = yield client.lrange(key, start, end);
return metrics.map(json_1.JsonService.maybeParse).filter(Boolean);
});
async extract(queue, start = 0, end = -1) {
const key = this._buildPersistKey(queue);
const client = await this._redisClient;
const metrics = await client.lrange(key, start, end);
return metrics.map(json_1.JsonService.maybeParse).filter(Boolean);
}
clear(queue) {
return __awaiter(this, void 0, void 0, function* () {
const client = yield this._redisClient;
yield client.del(this._buildPersistKey(queue));
});
async clear(queue) {
const client = await this._redisClient;
await client.del(this._buildPersistKey(queue));
}
clearAll() {
return __awaiter(this, void 0, void 0, function* () {
const client = yield this._redisClient;
const pipeline = client.pipeline();
this._queues.forEach((queue) => {
pipeline.del(this._buildPersistKey(queue.id));
});
yield pipeline.exec();
async clearAll() {
const client = await this._redisClient;
const pipeline = client.pipeline();
this._queues.forEach((queue) => {
pipeline.del(this._buildPersistKey(queue.id));
});
await pipeline.exec();
}

@@ -88,25 +73,26 @@ set queues(queues) {

}
_collect() {
return __awaiter(this, void 0, void 0, function* () {
const timestamp = Date.now();
return yield Promise.all(this._queues.map((queue) => __awaiter(this, void 0, void 0, function* () {
const processingTime = this._extractProcessingTime(queue.id);
this._processingTimeGauge.set(queue.id, []);
return Object.assign({ timestamp, queue: queue.id, counts: yield queue.getJobCounts() }, processingTime);
})));
});
async _collect() {
const timestamp = Date.now();
return await Promise.all(this._queues.map(async (queue) => {
const processingTime = this._extractProcessingTime(queue.id);
this._processingTimeGauge.set(queue.id, []);
return {
timestamp,
queue: queue.id,
counts: await queue.getJobCounts(),
...processingTime,
};
}));
}
_persist(metrics) {
return __awaiter(this, void 0, void 0, function* () {
const client = yield this._redisClient;
const lpopPipeline = client.pipeline();
yield Promise.all(metrics.map((metric) => __awaiter(this, void 0, void 0, function* () {
const key = this._buildPersistKey(metric.queue);
const listLen = yield client.rpush(key, JSON.stringify(metric));
if (listLen > this._config.maxMetrics) {
lpopPipeline.lpop(key);
}
})));
yield lpopPipeline.exec();
});
async _persist(metrics) {
const client = await this._redisClient;
const lpopPipeline = client.pipeline();
await Promise.all(metrics.map(async (metric) => {
const key = this._buildPersistKey(metric.queue);
const listLen = await client.rpush(key, JSON.stringify(metric));
if (listLen > this._config.maxMetrics) {
lpopPipeline.lpop(key);
}
}));
await lpopPipeline.exec();
}

@@ -125,18 +111,16 @@ _attachCompletionCbs() {

}
_onJobComplete(queue, jobId) {
return __awaiter(this, void 0, void 0, function* () {
const job = yield queue.getJob(jobId);
if (!(job === null || job === void 0 ? void 0 : job.finishedOn) || !job.processedOn) {
return;
}
const dur = job.finishedOn - job.processedOn;
const gauge = this._processingTimeGauge;
const stats = gauge.get(queue.id);
if (!stats) {
gauge.set(queue.id, [dur]);
}
else {
stats.push(dur);
}
});
async _onJobComplete(queue, jobId) {
const job = await queue.getJob(jobId);
if (!(job === null || job === void 0 ? void 0 : job.finishedOn) || !job.processedOn) {
return;
}
const dur = job.finishedOn - job.processedOn;
const gauge = this._processingTimeGauge;
const stats = gauge.get(queue.id);
if (!stats) {
gauge.set(queue.id, [dur]);
}
else {
stats.push(dur);
}
}

@@ -143,0 +127,0 @@ _extractProcessingTime(queue) {

{
"name": "@bull-monitor/root",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.1",
"repository": {

@@ -16,2 +16,5 @@ "type": "git",

"types": "dist/index.d.ts",
"engines": {
"node": ">=10"
},
"scripts": {

@@ -44,3 +47,3 @@ "build": "npm run clean && npm run compile",

},
"gitHead": "b511d2c95be7b44da396eee94a9f87d7dd4fafec"
"gitHead": "dee94fc851b8f3069dc8998eb9c621c715e21ad2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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