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

qjobs

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qjobs

qjobs is a simple and stupid queue job manager for nodejs

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7M
increased by4.88%
Maintainers
1
Weekly downloads
 
Created

What is qjobs?

The qjobs npm package is a lightweight, fast job queue manager for Node.js. It allows for efficient management of tasks with the ability to limit the number of concurrent jobs, making it suitable for scenarios where resource management and job scheduling are critical. It's particularly useful for managing CPU-intensive tasks or IO-bound operations in a controlled manner.

What are qjobs's main functionalities?

Job scheduling and concurrency control

This feature allows you to schedule jobs and control the number of jobs running concurrently. In the code sample, a new QJobs instance is created with a maximum concurrency of 5, meaning no more than 5 jobs will run at the same time. Jobs are added to the queue and executed with controlled concurrency.

const QJobs = require('qjobs');

const myQueue = new QJobs({maxConcurrency: 5});

const myJob = function(args, next) {
    console.log('Working on job with args', args);
    next();
};

for (let i = 0; i < 10; i++) {
    myQueue.add(myJob, [i]);
}

myQueue.run();

Job completion and error handling

This feature demonstrates how to handle job completion and errors. Jobs are defined with a condition to either complete successfully or fail. The QJobs instance listens for 'end' and 'error' events to handle job completion and errors respectively. This allows for robust error handling and notification upon job queue completion.

const QJobs = require('qjobs');

const myQueue = new QJobs();

const myJob = function(args, next) {
    if (args.shouldFail) {
        throw new Error('Job failed');
    } else {
        console.log('Job completed successfully');
        next();
    }
};

myQueue.on('end', function() {
    console.log('All jobs have been processed');
});

myQueue.on('error', function(err) {
    console.error('Error processing job:', err);
});

myQueue.add(myJob, [{shouldFail: false}]);
myQueue.add(myJob, [{shouldFail: true}]);

myQueue.run();

Other packages similar to qjobs

Keywords

FAQs

Package last updated on 19 Feb 2018

Did you know?

Socket

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.

Install

Related posts

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