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

cloudq-consumer

v0.1.1

Published

A CloudQ Consumer Api to make it easier to implement NodeWorkers

Downloads

4

Readme

CloudQ Consumer

Build Status

This module is a javascript api wrapper for consuming CloudQ Jobs.

example

var consumer = require('cloudq-consumer');

consumer({
  server: 'http://token:secret@localhost:3000/',
  queue: 'foo',
  interval: 2000
}).consume(function(job, complete, log) {
  ...
  //Do worker stuff here
  ...
  complete(null, job.id, function() { log.info('done'); } );
});

api

constructor

consumer(config)

config object server - name of the cloudq server (include auth in url) queue - name of the queue to monitor to consume jobs from interval - amount of time in between checks in milliseconds

the constructor returns a consumer instance with the following methods:

  • consume

consume

consume(function(job, complete, [log]) { complete(null, 'success', function() { }); });

The consume method get invoked every time a job is found and returned on the queue.

This is where you can handle your worker processing, the consume method takes a function which will be passed two paramters.

  • job - this is the job object being passed from CloudQ { id: 'XXXXX', klass: 'foo', args: [....] }
  • complete - this is a callback method that takes the following parameters:
    • error - if no error then pass null
    • id - in this param is the job id, so that the complete task can tell cloudq I am finished.
  • [log] - optional parameter to the bunyan logging system in case you want to log info on your worker

Usage

  • Create a new NodeJS Project
mkdir [project]
cd [project]
npm init
  • Install cloudq-consumer module
npm install cloudq-consumer --save
  • Use the example template above to get started.

** Be sure to create a README.md in your project

Testing

npm test

LICENSE

see LICENSE

Contributions

The api is straight forward and should remain simple, but all contributions are welcome in the form of pull requests.

Thank You

  • NodeJS Core Team
  • Underscore Team
  • Request Team
  • Flatiron/Nock Team
  • Mocha Team