Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
eko-queue-dispatcher
Advanced tools
EkoQueue is a queue manager that allows you to easily dispatch and process jobs with an easy to use interface. EkoQueue wraps the excellent kue.js and also comes with a UI to monitor and manage the queue jobs.
EkoQueue is meant to be fully scalable with no persistance on disk. The only dependency is a Redis server.
The queue module exposes a constructor function that accepts a hash of options.
host
(host for redis server)port
(port for redis server)prefix
(prefix to use for queue's jobs)jobsPath
(path to job classes)The queue dispatcher has a single method to dispatch jobs. The dispatch method takes the job name as the first paramater and following optional parameters act as the parameters for the handle method of the job class.
const EkoQueue = require('eko-queue')({});
const dispatcher = EkoQueue.dispatcher();
// Using additional parameters to pass through to the handle method
dispatcher.dispatch('email', 'andrew@ekoapp.com', 'Welcome Back!');
// Or you can just send an object through with your parameters
dispatcher.dispatch('email', {
email: 'andrew@ekoapp.com',
subject: 'Welcome Back!',
});
The queue processor has two (2) methods to process jobs. You can process a single job or process all the jobs. If running the processAll
method it will also subscribe to dispatched jobs even after it is started.
const EkoQueue = require('eko-queue')({});
const processor = EkoQueue.processor();
// Process individual job
processor.process('email');
// Process all jobs
processor.processAll();
The job classes are what the processor uses to process the job. Job classes must all live in the same directory and have a suffix of job in the filename. An example would be a job named email would have a filename of email-job.js
.
The job class require a handle
and failed
method that both accept optional parameters that will be passed from the dispatcher. The job classes can also contain optional concurrency
and priority
properties.
'use strict';
class EmailJob {
/**
* Number of jobs to run concurrently
* @return {number}
*/
get concurrency() {
return 1;
}
/**
* Priority of job 10 is lowest, -10 is highest
* @return {number}
*/
get priority() {
return 0;
}
/**
* Handle job
* @param {string} email
* @param {string} subject
*/
* handle(email, subject) {
console.log(`Sending email to ${email} with the subject ${subject}`);
}
/**
* Handle job failure
* @param {string} email
* @param {string} subject
*/
* failed(email, subject) {
console.error(`Failed sending email to ${email} with the subject ${subject}`);
}
}
module.exports = EmailJob;
npm test
to run the test suitenpm run lint
to run the linterCheckout this repository and run the following in two (2) different terminal sessions. The order does not matter.
$ DEBUG=eko* nodemon examples/process.js
$ DEBUG=eko* nodemon examples/dispatch.js
Todo: Export server from constructor. In the mean time you can checkout this repository and run npm run server
.
FAQs
Eko queue dispatcher
The npm package eko-queue-dispatcher receives a total of 0 weekly downloads. As such, eko-queue-dispatcher popularity was classified as not popular.
We found that eko-queue-dispatcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.