Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including redis-queuesize-poller with all npm packages installed. Try it out:

var redisQueuesizePoller = require("redis-queuesize-poller")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

redis-queuesize-poller v0.1.3

Polls redis at specified interval to fetch the size of a list of queues and exposes results via a getter

redis-queuesize-poller

Polls redis at specified interval to fetch the size of a list of queues and exposes results via a getter.

Useful for a monitoring endpoint, to report how much stuff you have in your Redis queue.

Basic usage:

var RedisQueueSizePoller = require('../index');
var Redis = require('redis');
var redis = Redis.createClient();
var poller = new RedisQueueSizePoller({}, ['wow1', 'wow2', 'wow3']);

redis.multi()
  .rpush('wow1', '1')
  .rpush('wow1', '2')
  .rpush('wow1', '3')
  .rpush('wow1', '4')
  .rpush('wow2', '1')
  .rpush('wow2', '2')
  .rpush('wow3', '1')
  .rpush('wow3', '2')
  .rpush('wow3', '3')
  .exec(function (err, result) {
    setTimeout(function () {
      var sizes = poller.getQueueSizes();
      console.log(sizes);
      poller.close();
      redis.close();
    }, 5000);

...produces:

{ one: 4, two: 2, three: 3 }

See tests for more examples.

Licence

ISC

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free