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

node-resque-data

v0.0.17

Published

extract node-resque data

Downloads

6

Readme

node-resque-data

NPM Version Linux Build

This package can be used to grab node-resque data such as queue lengths and the number of scheduled jobs outstanding.

It can also be used to visualise node-resque data via express middleware.

Installation

npm install node-resque-data

Usage:

View raw queue information

const {Queue} = require('node-resque-data')

const config = {
  port: 6379, // Optional - defaults to 6379
  host: 'localhost', // Optional - defaults to 'localhost'
  password: "redis-pw",
  db: 0, // Optional - defaults to 0
  family: 4, // Optional - defaults to 4 for IPv4 or 6 for IPv6
  queues: ['nameOfQueue1', 'nameOfQueue2', 'nameOfQueue3'],
  namespace: 'beepbop', // Optional - defaults to 'resque'
};

const result = await Queue.queueData(config);
console.log(result)

example output

{
  queues: [
    { queue: 'nameOfQueue1', num: 190 },
    { queue: 'nameOfQueue2', num: 12 },
    { queue: 'nameOfQueue3', num: 207 },
  ],
  jobs: { processed: '8302', failed: '12', failing: 0 }
}

view queue information using .then

Queue.queueData(config).then((result) => {
  console.log(result)
});

view schedule information

const result = await Queue.scheduledData(config);
console.log(result)

Example output:

{
  scheduledJobs: 2
}

include more information about the scheduled jobs

const options = {
  includeJobDetails: true
};

const result = await Queue.scheduledData(config, options);
console.log(result)

Example output:

{
  scheduledJobs: 2,
  scheduledJobsDetails: [
    {
      class: 'subtract',
      queue: 'nameOfQueue1',
      args: [ 2, 1 ],
      runTime: 2021-08-15T19:36:27.000Z
   }
  ]
}

integrate node-resque-data with express middleware

The below snippet will display the same example output displayed above but this time to an express route you specify.

const {Queue} = require('node-resque-data')

const config = {
  queues: ['nameOfQueue1', 'nameOfQueue2', 'nameOfQueue3'],
};

const options = {
  rawJSON: true
};

// add route via express middleware
app.use('/some-route', Queue.serve, Queue.setup(config, options));

Visualise node-resque data

To acheive this simply remove the {rawJSON: true} object from the queue.setup function or even set it to false

This will display the node-resque queue data in a bar and pie chart.

Custom options:

Custom settings can be added by passing additional keys into the options object.

const options = {
  rawJSON: false,
  customTitle: 'Your Custom title',
  customHeader: 'Your Custom header value',
};

app.use('/some-route', Queue.serve, Queue.setup(config, options));

Custom option fields:

  • rawJSON: boolean field, that determines if the page displays a raw JSON display of queue lengths or a visual display.
  • customTitle: Allows you to customise the browser tab title
  • customHeader: Allows you to customise the text shown in the header

Custom Css

Custom CSS can be added by passing a third parameter into the setup function.

This will allow you to totally change the look and feel of the UI

const customCss = `
  body {
    color: red;
    font-size: 8px;
  };
`;

app.use('/some-route', Queue.serve, Queue.setup(queueUiConfig, options, customCss));

Run tests

npm run test

Run eslint

display linting warnings and errors

npm run lint

fix linting warnings and errors

npm run lint:fix