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

node-resque

Package Overview
Dependencies
Maintainers
2
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 0.3.1 to 0.3.2

examples/customPluginExample.js

22

lib/pluginRunner.js

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

var runPlugin = function(pluginName, type, func, queue, job, args, callback){
var runPlugin = function(pluginRefrence, type, func, queue, job, args, callback){
var self = this;

@@ -7,2 +7,8 @@ process.nextTick(function(){

}else{
var pluginName = pluginRefrence;
if(typeof pluginRefrence === 'function'){
pluginName = new pluginRefrence().name;
}
if(self.jobs[func]['pluginOptions'] != null && self.jobs[func]['pluginOptions'][pluginName] != null){

@@ -13,11 +19,13 @@ var pluginOptions = self.jobs[func]['pluginOptions'][pluginName]

}
var plugin = null
if (typeof pluginName === 'string') {
var pluginConstructor = require(__dirname + "/plugins/" + pluginName + ".js")[pluginName];
if (typeof pluginRefrence === 'string') {
var pluginConstructor = require(__dirname + "/plugins/" + pluginRefrence + ".js")[pluginRefrence];
plugin = new pluginConstructor(self, func, queue, job, args, pluginOptions);
} else if (typeof pluginName === 'function') {
plugin = new pluginName(self, func, queue, job, args, pluginOptions);
} else if (typeof pluginRefrence === 'function') {
plugin = new pluginRefrence(self, func, queue, job, args, pluginOptions);
} else {
throw new Error('Plugin must be the constructor name or an object');
}
if(plugin[type] == null || typeof plugin[type] != "function"){

@@ -44,4 +52,4 @@ callback(null, true);

}else{
var pluginName = job["plugins"][pluginCounter];
self.runPlugin(pluginName, type, func, queue, job, args, function(err, toRun){
var pluginRefrence = job["plugins"][pluginCounter];
self.runPlugin(pluginRefrence, type, func, queue, job, args, function(err, toRun){
pluginCounter++;

@@ -48,0 +56,0 @@ if(toRun === false){

@@ -5,2 +5,3 @@ // If a job with the same name, queue, and args is already in the delayed queue(s), do not enqueue it again

var self = this;
self.name = 'delayQueueLock';
self.worker = worker;

@@ -7,0 +8,0 @@ self.queue = queue;

@@ -5,2 +5,3 @@ // If a job with the same name, queue, and args is already running, put this job back in the queue and try later

var self = this;
self.name = 'jobLock';
self.worker = worker;

@@ -7,0 +8,0 @@ self.queue = queue;

@@ -5,2 +5,3 @@ // If a job with the same name, queue, and args is already in the queue, do not enqueue it again

var self = this;
self.name = 'queueLock';
self.worker = worker;

@@ -7,0 +8,0 @@ self.queue = queue;

@@ -5,3 +5,3 @@ {

"description": "an opinionated implementation of resque in node",
"version": "0.3.1",
"version": "0.3.2",
"homepage": "http://github.com/taskrabbit/node-resque",

@@ -21,4 +21,4 @@ "repository": {

"devDependencies": {
"mocha": "1.9.x",
"should": "1.2.x"
"mocha": "1.17.x",
"should": "2.1.x"
},

@@ -25,0 +25,0 @@ "scripts": {

@@ -162,2 +162,3 @@ # node-resque

var self = this;
self.name = 'myPlugin';
self.worker = worker;

@@ -235,5 +236,3 @@ self.queue = queue;

## Acknowledgments
Most of this code was inspired by / stolen from [coffee-resque](https://npmjs.org/package/coffee-resque) and [coffee-resque-scheduler](https://github.com/leeadkins/coffee-resque-scheduler). Thanks!
// Simple plugin to prevent all jobs
var CustomPlugin = function(worker, func, queue, job, args, options){
var self = this;
self.name = 'CustomPlugin';
self.worker = worker;

@@ -5,0 +6,0 @@ self.queue = queue;

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