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

node-resque

Package Overview
Dependencies
Maintainers
4
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-resque - npm Package Compare versions

Comparing version 8.1.0 to 8.2.0

dist/plugins/index.d.ts

6

__tests__/plugins/delayedQueueLock.ts
import specHelper from "../utils/specHelper";
import { Plugin, Queue, Worker } from "../../src";
import { Plugin, Queue, Plugins, Worker } from "../../src";

@@ -9,3 +9,3 @@ let queue;

slowAdd: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: { jobLock: {} },

@@ -21,3 +21,3 @@ perform: async (a, b) => {

uniqueJob: {
plugins: ["DelayQueueLock"],
plugins: [Plugins.DelayQueueLock],
pluginOptions: { queueLock: {}, delayQueueLock: {} },

@@ -24,0 +24,0 @@ perform: async (a, b) => {

import specHelper from "../utils/specHelper";
import { Queue, Worker } from "../../src";
import { Queue, Plugins, Worker } from "../../src";

@@ -11,3 +11,3 @@ let queue;

slowAdd: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: { jobLock: {} },

@@ -23,3 +23,3 @@ perform: async (a, b) => {

withoutReEnqueue: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: { JobLock: { reEnqueue: false } },

@@ -96,3 +96,3 @@ perform: async () => {

expect(new Date().getTime() - startTime).toBeLessThan(jobDelay * 3);
resolve();
resolve(null);
}

@@ -123,3 +123,3 @@ };

jobLockAdd: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: {

@@ -126,0 +126,0 @@ JobLock: {

import specHelper from "../utils/specHelper";
import { Scheduler, Queue, Worker } from "../../src";
import { Scheduler, Plugins, Queue, Worker } from "../../src";

@@ -10,3 +10,3 @@ let queue;

brokenJob: {
plugins: ["Noop"],
plugins: [Plugins.Noop],
pluginOptions: {

@@ -24,3 +24,3 @@ Noop: {

happyJob: {
plugins: ["Noop"],
plugins: [Plugins.Noop],
pluginOptions: {

@@ -27,0 +27,0 @@ Noop: {

import specHelper from "../utils/specHelper";
import { Plugin, Queue, Worker } from "../../src";
import { Plugin, Plugins, Queue, Worker } from "../../src";

@@ -26,3 +26,3 @@ let queue;

uniqueJob: {
plugins: ["QueueLock"],
plugins: [Plugins.QueueLock],
pluginOptions: { queueLock: {}, delayQueueLock: {} },

@@ -32,3 +32,3 @@ perform: (a, b) => a + b,

blockingJob: {
plugins: ["QueueLock", NeverRunPlugin],
plugins: [Plugins.QueueLock, NeverRunPlugin],
perform: (a, b) => a + b,

@@ -35,0 +35,0 @@ },

import specHelper from "../utils/specHelper";
import { Scheduler, Queue, Worker } from "../../src";
import { Scheduler, Plugins, Queue, Worker } from "../../src";

@@ -9,3 +9,3 @@ let queue;

brokenJob: {
plugins: ["Retry"],
plugins: [Plugins.Retry],
pluginOptions: {

@@ -22,3 +22,3 @@ Retry: {

happyJob: {
plugins: ["Retry"],
plugins: [Plugins.Retry],
pluginOptions: {

@@ -142,3 +142,3 @@ Retry: {

jobWithRetryCount: {
plugins: ["Retry"],
plugins: [Plugins.Retry],
pluginOptions: {

@@ -198,3 +198,3 @@ Retry: {

jobWithBackoffStrategy: {
plugins: ["Retry"],
plugins: [Plugins.Retry],
pluginOptions: {

@@ -201,0 +201,0 @@ Retry: {

/// <reference types="node" />
import { EventEmitter } from "events";
import * as IORedis from "ioredis";
import { ConnectionOptions } from "../types/options";
import { ConnectionOptions } from "..";
export declare class Connection extends EventEmitter {

@@ -6,0 +6,0 @@ options: ConnectionOptions | null;

@@ -47,3 +47,2 @@ "use strict";

this.redis = this.options.redis;
await connectionTestAndLoadLua();
}

@@ -50,0 +49,0 @@ else {

@@ -5,4 +5,3 @@ /// <reference types="node" />

import { MultiWorkerOptions } from "../types/options";
import { Jobs } from "../types/jobs";
import { Job, JobEmit } from "../types/job";
import { Jobs, Job, JobEmit } from "..";
export declare interface MultiWorker {

@@ -9,0 +8,0 @@ options: MultiWorkerOptions;

@@ -7,3 +7,3 @@ "use strict";

const worker_1 = require("./worker");
const eventLoopDelay_1 = require("./../utils/eventLoopDelay");
const eventLoopDelay_1 = require("../utils/eventLoopDelay");
class MultiWorker extends events_1.EventEmitter {

@@ -153,3 +153,3 @@ constructor(options, jobs) {

await this.cleanupWorker(worker);
return resolve();
return resolve(null);
}));

@@ -156,0 +156,0 @@ });

@@ -6,3 +6,4 @@ "use strict";

constructor(worker, func, queue, job, args, options) {
this.name = "CustomPlugin";
var _a;
this.name = ((_a = this === null || this === void 0 ? void 0 : this.constructor) === null || _a === void 0 ? void 0 : _a.name) || "Node Resque Plugin";
this.worker = worker;

@@ -9,0 +10,0 @@ this.queue = queue;

@@ -5,8 +5,6 @@ "use strict";

async function RunPlugins(self, type, func, queue, job, args, pluginCounter) {
if (!pluginCounter) {
if (!job)
return true;
if (!pluginCounter)
pluginCounter = 0;
}
if (!job) {
return true;
}
if (job.plugins === null ||

@@ -17,11 +15,9 @@ job.plugins === undefined ||

}
if (pluginCounter >= job.plugins.length) {
if (pluginCounter >= job.plugins.length)
return true;
}
const pluginRefrence = job.plugins[pluginCounter];
const toRun = await RunPlugin(self, pluginRefrence, type, func, queue, job, args);
pluginCounter++;
if (toRun === false) {
if (toRun === false)
return false;
}
return RunPlugins(self, type, func, queue, job, args, pluginCounter);

@@ -31,5 +27,4 @@ }

async function RunPlugin(self, PluginRefrence, type, func, queue, job, args) {
if (!job) {
if (!job)
return true;
}
let pluginName = PluginRefrence;

@@ -36,0 +31,0 @@ if (typeof PluginRefrence === "function") {

/// <reference types="node" />
import { EventEmitter } from "events";
import { ErrorPayload } from "../types/errorPayload";
import { Jobs } from "../types/jobs";
import { ConnectionOptions } from "../types/options";
import { ErrorPayload, Jobs, ConnectionOptions } from "..";
import { Connection } from "./connection";

@@ -7,0 +5,0 @@ export declare interface Queue {

/// <reference types="node" />
import { EventEmitter } from "events";
import { ErrorPayload } from "../types/errorPayload";
import { Job } from "../types/job";
import { Jobs } from "../types/jobs";
import { ErrorPayload, Job, Jobs } from "..";
import { SchedulerOptions } from "../types/options";

@@ -7,0 +5,0 @@ import { Connection } from "./connection";

@@ -73,3 +73,3 @@ "use strict";

await this.end();
resolve();
resolve(null);
}, this.options.timeout / 2);

@@ -76,0 +76,0 @@ });

/// <reference types="node" />
import { EventEmitter } from "events";
import { Job, JobEmit } from "../types/job";
import { Jobs } from "../types/jobs";
import { Job, JobEmit, Jobs } from "..";
import { WorkerOptions } from "../types/options";

@@ -6,0 +5,0 @@ import { Connection } from "./connection";

@@ -73,3 +73,3 @@ "use strict";

setTimeout(() => {
resolve();
resolve(null);
}, this.options.timeout);

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

this.poll();
resolve();
resolve(null);
}, this.options.timeout);

@@ -252,0 +252,0 @@ });

@@ -7,2 +7,3 @@ export { Connection } from "./core/connection";

export { Plugin } from "./core/plugin";
export { default as Plugins } from "./plugins";
export { ConnectionOptions } from "./types/options";

@@ -9,0 +10,0 @@ export { Job, JobEmit } from "./types/job";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plugin = exports.MultiWorker = exports.Worker = exports.Scheduler = exports.Queue = exports.Connection = void 0;
exports.Plugins = exports.Plugin = exports.MultiWorker = exports.Worker = exports.Scheduler = exports.Queue = exports.Connection = void 0;
var connection_1 = require("./core/connection");

@@ -16,1 +16,3 @@ Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_1.Connection; } });

Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return plugin_1.Plugin; } });
var plugins_1 = require("./plugins");
Object.defineProperty(exports, "Plugins", { enumerable: true, get: function () { return plugins_1.default; } });

@@ -1,1 +0,7 @@

export {};
import { Plugin } from "..";
export declare class DelayQueueLock extends Plugin {
beforeEnqueue(): Promise<boolean>;
afterEnqueue(): boolean;
beforePerform(): boolean;
afterPerform(): boolean;
}
"use strict";
// If a job with the same name, queue, and args is already in the delayed queue(s), do not enqueue it again
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./../index");
class DelayQueueLock extends index_1.Plugin {
exports.DelayQueueLock = void 0;
const __1 = require("..");
class DelayQueueLock extends __1.Plugin {
async beforeEnqueue() {

@@ -26,1 +27,2 @@ const timestamps = await this.queueObject.scheduledAt(this.queue, this.func, this.args);

exports.DelayQueueLock = DelayQueueLock;
exports.DelayQueueLock = DelayQueueLock;

@@ -1,2 +0,2 @@

import { Plugin } from "./../index";
import { Plugin } from "..";
export declare class JobLock extends Plugin {

@@ -3,0 +3,0 @@ beforeEnqueue(): boolean;

@@ -5,4 +5,4 @@ "use strict";

// If a job with the same name, queue, and args is already running, put this job back in the queue and try later
const index_1 = require("./../index");
class JobLock extends index_1.Plugin {
const __1 = require("..");
class JobLock extends __1.Plugin {
beforeEnqueue() {

@@ -9,0 +9,0 @@ return true;

@@ -1,2 +0,2 @@

import { Plugin } from "./../index";
import { Plugin } from "..";
export declare class Noop extends Plugin {

@@ -3,0 +3,0 @@ afterPerform(): boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Noop = void 0;
const index_1 = require("./../index");
class Noop extends index_1.Plugin {
const __1 = require("..");
class Noop extends __1.Plugin {
afterPerform() {

@@ -7,0 +7,0 @@ if (this.worker.error) {

@@ -1,2 +0,2 @@

import { Plugin } from "./../index";
import { Plugin } from "..";
export declare class QueueLock extends Plugin {

@@ -3,0 +3,0 @@ beforeEnqueue(): Promise<boolean>;

@@ -5,4 +5,4 @@ "use strict";

exports.QueueLock = void 0;
const index_1 = require("./../index");
class QueueLock extends index_1.Plugin {
const __1 = require("..");
class QueueLock extends __1.Plugin {
async beforeEnqueue() {

@@ -9,0 +9,0 @@ const key = this.key();

/// <reference types="ioredis" />
import { Plugin } from "./../index";
import { Plugin } from "..";
export declare class Retry extends Plugin {

@@ -4,0 +4,0 @@ constructor(worker: any, func: any, queue: any, job: any, args: any, options: any);

@@ -7,4 +7,4 @@ "use strict";

const os = require("os");
const index_1 = require("./../index");
class Retry extends index_1.Plugin {
const __1 = require("..");
class Retry extends __1.Plugin {
constructor(worker, func, queue, job, args, options) {

@@ -11,0 +11,0 @@ super(worker, func, queue, job, args, options);

import * as IORedis from "ioredis";
import { Connection } from "../core/connection";
import { Connection } from "..";
export interface ConnectionOptions {

@@ -4,0 +4,0 @@ pkg?: string;

#!/usr/bin/env ts-node
import { Queue, Scheduler, Worker } from "../src";
import { Queue, Plugins, Scheduler, Worker } from "../src";
/* In your projects:
import { Queue, Scheduler, Worker } from "node-resque";
import { Queue, Plugins, Scheduler, Worker } from "node-resque";
*/

@@ -27,3 +27,3 @@

add: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: {

@@ -30,0 +30,0 @@ JobLock: {},

#!/usr/bin/env ts-node
import { Queue, Scheduler, Worker } from "../src";
import { Queue, Plugins, Scheduler, Worker } from "../src";
/* In your projects:
import { Queue, Scheduler, Worker } from "node-resque";
import { Queue, Plugins, Scheduler, Worker } from "node-resque";
*/

@@ -32,3 +32,3 @@

add: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: {

@@ -35,0 +35,0 @@ JobLock: {},

#!/usr/bin/env ts-node
import { Queue, Scheduler, Worker } from "../src";
import { Queue, Plugins, Scheduler, Worker } from "../src";
/* In your projects:
import { Queue, Scheduler, Worker } from "node-resque";
import { Queue, Plugins, Scheduler, Worker } from "node-resque";
*/

@@ -29,3 +29,3 @@

add: {
plugins: ["Retry"],
plugins: [Plugins.Retry],
pluginOptions: {

@@ -32,0 +32,0 @@ Retry: {

@@ -6,3 +6,3 @@ {

"license": "Apache-2.0",
"version": "8.1.0",
"version": "8.2.0",
"homepage": "http://github.com/actionhero/node-resque",

@@ -33,13 +33,13 @@ "repository": {

"devDependencies": {
"@types/ioredis": "^4.17.7",
"@types/jest": "^26.0.15",
"@types/node": "^14.14.6",
"ioredis-mock": "^5.1.0",
"@types/ioredis": "^4.17.8",
"@types/jest": "^26.0.16",
"@types/node": "^14.14.10",
"ioredis-mock": "^5.2.0",
"jest": "^26.6.3",
"node-schedule": "^1.3.2",
"prettier": "^2.1.2",
"ts-jest": "^26.4.3",
"ts-node": "^9.0.0",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"ts-node": "^9.1.0",
"typedoc": "^0.19.2",
"typescript": "^4.0.5"
"typescript": "^4.1.2"
},

@@ -46,0 +46,0 @@ "jest": {

@@ -26,3 +26,3 @@ # node-resque: The best background jobs in node.

```javascript
import { Worker, Scheduler, Queue } from "node-resque";
import { Worker, Plugins, Scheduler, Queue } from "node-resque";

@@ -53,3 +53,3 @@ async function boot() {

add: {
plugins: ["JobLock"],
plugins: [Plugins.JobLock],
pluginOptions: {

@@ -474,3 +474,3 @@ JobLock: { reEnqueue: true },

add: {
plugins: ["MyPlugin"],
plugins: [MyPlugin],
pluginOptions: {

@@ -491,3 +491,3 @@ MyPlugin: { thing: "stuff" },

- If you are writing a plugin to deal with errors which may occur during your resque job, you can inspect and modify `this.worker.error` in your plugin. If `this.worker.error` is null, no error will be logged in the resque error queue.
- There are a few included plugins, all in the lib/plugins/\* directory. You can rewrite you own and include it like this:
- There are a few included plugins, all in the `src/plugins/*` directory. You can write your own and include it like this:

@@ -494,0 +494,0 @@ ```javascript

@@ -7,3 +7,3 @@ /// <reference path="./../../node_modules/@types/ioredis/index.d.ts" />

import * as path from "path";
import { ConnectionOptions } from "../types/options";
import { ConnectionOptions } from "..";

@@ -62,3 +62,2 @@ interface EventListeners {

this.redis = this.options.redis;
await connectionTestAndLoadLua();
} else {

@@ -65,0 +64,0 @@ const Pkg = require(this.options.pkg);

import { EventEmitter } from "events";
import * as os from "os";
import { Worker } from "./worker";
import { EventLoopDelay } from "./../utils/eventLoopDelay";
import { EventLoopDelay } from "../utils/eventLoopDelay";
import { MultiWorkerOptions } from "../types/options";
import { Jobs } from "../types/jobs";
import { Job, JobEmit } from "../types/job";
import { Jobs, Job, JobEmit } from "..";

@@ -257,3 +256,3 @@ export declare interface MultiWorker {

await this.cleanupWorker(worker);
return resolve();
return resolve(null);
})

@@ -260,0 +259,0 @@ );

@@ -20,3 +20,3 @@ import { Worker } from "./worker";

constructor(worker, func, queue, job, args, options) {
this.name = "CustomPlugin";
this.name = this?.constructor?.name || "Node Resque Plugin";
this.worker = worker;

@@ -23,0 +23,0 @@ this.queue = queue;

@@ -10,8 +10,4 @@ export async function RunPlugins(

) {
if (!pluginCounter) {
pluginCounter = 0;
}
if (!job) {
return true;
}
if (!job) return true;
if (!pluginCounter) pluginCounter = 0;
if (

@@ -24,5 +20,3 @@ job.plugins === null ||

}
if (pluginCounter >= job.plugins.length) {
return true;
}
if (pluginCounter >= job.plugins.length) return true;

@@ -40,5 +34,3 @@ const pluginRefrence = job.plugins[pluginCounter];

pluginCounter++;
if (toRun === false) {
return false;
}
if (toRun === false) return false;

@@ -57,5 +49,3 @@ return RunPlugins(self, type, func, queue, job, args, pluginCounter);

) {
if (!job) {
return true;
}
if (!job) return true;

@@ -62,0 +52,0 @@ let pluginName = PluginRefrence;

import { EventEmitter } from "events";
import * as os from "os";
import { ErrorPayload } from "../types/errorPayload";
import { Jobs } from "../types/jobs";
import { ConnectionOptions } from "../types/options";
import { ErrorPayload, Jobs, ConnectionOptions } from "..";
import { Connection } from "./connection";

@@ -7,0 +5,0 @@ import { RunPlugins } from "./pluginRunner";

@@ -6,5 +6,3 @@ // To read notes about the leader locking scheme, check out:

import * as os from "os";
import { ErrorPayload } from "../types/errorPayload";
import { Job } from "../types/job";
import { Jobs } from "../types/jobs";
import { ErrorPayload, Job, Jobs } from "..";
import { SchedulerOptions } from "../types/options";

@@ -135,3 +133,3 @@ import { Connection } from "./connection";

await this.end();
resolve();
resolve(null);
}, this.options.timeout / 2);

@@ -138,0 +136,0 @@ });

import { EventEmitter } from "events";
import * as os from "os";
import { Job, JobEmit } from "../types/job";
import { Jobs } from "../types/jobs";
import { Job, JobEmit, Jobs } from "..";
import { WorkerOptions } from "../types/options";

@@ -173,3 +172,3 @@ import { Connection } from "./connection";

setTimeout(() => {
resolve();
resolve(null);
}, this.options.timeout);

@@ -412,3 +411,3 @@ });

this.poll();
resolve();
resolve(null);
}, this.options.timeout);

@@ -415,0 +414,0 @@ });

@@ -7,2 +7,3 @@ export { Connection } from "./core/connection";

export { Plugin } from "./core/plugin";
export { default as Plugins } from "./plugins";

@@ -9,0 +10,0 @@ export { ConnectionOptions } from "./types/options";

// If a job with the same name, queue, and args is already in the delayed queue(s), do not enqueue it again
import { Plugin } from "./../index";
import { Plugin } from "..";
class DelayQueueLock extends Plugin {
export class DelayQueueLock extends Plugin {
async beforeEnqueue() {

@@ -7,0 +7,0 @@ const timestamps = await this.queueObject.scheduledAt(

// If a job with the same name, queue, and args is already running, put this job back in the queue and try later
import { Plugin } from "./../index";
import { Plugin } from "..";

@@ -4,0 +4,0 @@ export class JobLock extends Plugin {

@@ -1,2 +0,2 @@

import { Plugin } from "./../index";
import { Plugin } from "..";

@@ -3,0 +3,0 @@ export class Noop extends Plugin {

// If a job with the same name, queue, and args is already in the queue, do not enqueue it again
import { Plugin } from "./../index";
import { Plugin } from "..";

@@ -5,0 +5,0 @@ export class QueueLock extends Plugin {

@@ -5,3 +5,3 @@ // If a job fails, retry it N times before finally placing it into the failed queue

import * as os from "os";
import { Plugin } from "./../index";
import { Plugin } from "..";

@@ -8,0 +8,0 @@ export class Retry extends Plugin {

/// <reference path="./../../node_modules/@types/ioredis/index.d.ts" />
import * as IORedis from "ioredis";
import { Connection } from "../core/connection";
import { Connection } from "..";

@@ -5,0 +5,0 @@ export interface ConnectionOptions {

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