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

@condor-labs/bull-arena

v1.1.4

Published

This module provide and useful helper to use bull library

Downloads

382

Readme

This module provides a useful helper to use the official bull-arena library.

See official documentation here.

Compatibility

The minimum supported version of Node.js is v8.

How to use it

To use the library you just need to follow the following steps.

Install the library with npm:

npm install @condor-labs/bull-arena

Import the library:

const bull = require('@condor-labs/bull-arena')(settings);

settings object properties

|Object| Property | Datatype | Default | Description | |------|-----------|-----------|-----------|-------------| |redis| port | Number | 6379 | The port number to connect to.| |redis| host | String | 127.0.0.1 | The hostname of the database you are connecting to.| |redis| password | String | | The password of that Redis user.| |options| removeOnComplete, removeOnFail, attempts, etc | | | You can check all the spoible options in the official documentation|

Examples

constants.js

module.exports = {
    settings: {
      redis : {
            port: 6379,
            host: "127.0.0.1",
            password: "1"
        },
        options : {
            removeOnComplete: 100,
            removeOnFail: 100000,
            attempts: 3
        }
    }
};

index.js

const {
    settings
} = require('./constants');

try {
   // init bull-arena object
    const bull = require('@condor-labs/bull-arena')(settings);

    let queueName = 'queue-001';

    const messages = [
      { "data": {
          "id": 1604701460473,
          "entityId": "5fa95d342390fabc79815f4b",
          "data": {
              "header_id": "5fa95d342390fabc79815f4b",
              "sort_by": ["license.professionCode"]
          }
        }
      },
      { "data": {
          "id": 1473604701460,
          "entityId": "c79815f4b5fa95d342390fab",
          "data": {
              "header_id": "15f4b5fa95d342390fabc798",
              "sort_by": ["license.licenseCode"]
          }
        }
      }
    ];

    //get a queue instance, If the queue doesn't exist, the queue is created.
    await bull.getQueue(queueName);

    //Add multiple messages to a queue. if the queue doesn't exist, the queue is created.
    await bull.pushBulk(queueName, messages);

    // We can pause the queue
    await bull.pause(queueName);

    //We can also check if the queue is paused.
    let isPausedQueue = await bull.isPaused(queueName);

    
    //Wait for 10 seconds (JUST FOR TESTING PURPOSES)
    console.log("is paused de queue : ",isPausedQueue);
    setTimeout(async function () {
        console.log("resume the queue after 10 seconds");
        await bull.resume(queueName);
    }, 10 * 1000);

    //We can also add just one message (Job) to a queue. if the queue doesn't exist, the queue is created.
    await bull.add(queueName, `new-job-for-${queueName}`,messages[0], null);

    //The next function is the one we are going to use to process the messages (Jobs) in the queue.
    let job = async function(job){
        console.info(`running job! queue ${job.queue.name}, with id ${job.id} and name ${job.name}`);
        console.log("data sent at job", job.data);
        return true;
    };

    //Finally, we can register the function in the queue to start processing the messages (Jobs).
    await bull.process(queueName,'*',job);

} catch (error) {
    console.error(error)
}

Conclusion

A Bull-Arena Queue has the concept of FIRST-IN-FIRST-OUT which can map orders that are carried out simultaneously (asynchronously) to be ordered and take turns one by one (synchronous).

How to Publish

Increasing package version

You will need to update the package.json file placed in the root folder.

identify the property version and increase the right number in plus one.

Login in NPM by console.

 npm login
 [Enter username]
 [Enter password]
 [Enter email]

If all is ok the console will show you something like this : Logged in as USERNAME on https://registry.npmjs.org/.

Uploading a new version

 npm publish --access public

Ref: https://docs.npmjs.com/getting-started/publishing-npm-packages

Note: you will need to have a NPM account, if you don't have one create one here: https://www.npmjs.com/signup

Contributors

The original author and current lead maintainer of this module is the @condor-labs development team.

More about Condorlabs Here.

License

MIT