npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@abhihyder/queueable

v0.0.2

Published

A versatile JavaScript utility for simplifying queue management in applications, serving as an abstraction layer over Bull, a Redis-backed queue package for Node.js. Ideal for building scalable and efficient JavaScript applications.

Downloads

9

Readme

Queueable

A versatile JavaScript utility for simplifying queue management in applications, serving as an abstraction layer over Bull, a Redis-backed queue package for Node.js. Ideal for building scalable and efficient JavaScript applications.

Why Use Queueable?

  • Minimal Boilerplate Code: Avoid writing extensive code for queue instantiation, Redis connection, and cleanup. Queueable handles these tasks seamlessly for you.
  • Easy to Use: Just extend the Queueable class and implement your handler method.
  • Customizable: Supports custom Redis configurations through a simple queueable.config.js file.

With Queueable, you don't need to write a lot of code to:

  • Get a queue instance
  • Close the Redis connection after completion
  • Close the queue after completion

Everything is handled efficiently within the library.

Installation

Install via npm:

npm install @abhihyder/queueable

Usage

Before using @abhihyder/queueable, make sure you have a Redis server installed and running.

const Queueable = require("@abhihyder/queueable");

class ExampleJob extends Queueable {
  handler(data) {
    console.log("Processing job with data:", data);
  }

  completed(job, result) {
    console.log(`Job ${job.id} completed with result: ${result}`);
  }

  failed(job, result) {
    console.log(`Job ${job.id} failed with result: ${result}`);
  }
}

const job = new ExampleJob();
job.dispatch({data:""});

Methods

handler(data)

You must implement this method in your derived class to define the job's main logic. The data passed to the dispatch method will be available in the handler method to perform the necessary logic.

completed(job, result) (Optional)

This method is called when a job is completed successfully. You can override it in your derived class to perform actions on job completion.

failed(job, result) (Optional)

This method is called when a job fails. You can override it in your derived class to perform actions on job failure.

Note: The methods dispatch, queueHandler, and queueInstance are reserved for internal use by the Queueable class and should not be overridden in derived classes.

Configuration

Create a queueable.config.js file in your application's root directory to customize the Redis configuration for Bull. If not provided, default configuration values will be used.

Example queueable.config.js:

module.exports = {
  redis: {
    host: "127.0.0.1",
    port: 6379,
    username: "",
    password: ""
  }
};

License

This project is licensed under the MIT License.