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

work-q

v1.0.0

Published

Worker queue interface for AMQP

Downloads

3

Readme

work-q Build Status

Worker queue interface for AMQP

Install

$ npm install --save work-q

Usage

const Worker = require('work-q')
const worker = Worker({
  connection: 'amqp://localhost'  
})

worker.connect(function (err) {
  if (err) return fail(err)

  worker.listen('my-queue', function (err) {
    if (err) return fail(err)
  })
})

worker.on('data', function (queue, data, callback) {
  console.log('new message on ' + queue)
  console.log(JSON.stringify(data))
  callback()
})

function fail (err) {
  console.error(err)
  return process.exit(1)
}

API

Worker(options) -> worker

Constructs a new worker.

options

Options for configuring the worker's behavior.

connection

Required
Type: string

An AMQP connection string.

parse

Type: function
Default: JSON.parse

A function used to parsed the inbound messages.

worker.connect(callback) -> undefined

Connects to the AMQP server and establishes a channel.

callback

Required
Type: function
Arguments: err

A callback to be called when the connection and channel are established and usable.

worker.close(callback) -> undefined

Closes the worker connection.

callback

Required
Type: function
Arguments: err

A callback to be called when the connection is closed.

worker.listen(queue, callback) -> undefined

Listens on new messages in a queue.

queue

Required
Type: string

The queue to consume.

callback

Required
Type: function
Arguments: err

A callback to be called when the worker is listening on the queue.

worker.unlisten(queue, callback) -> undefined

Stops listening on new messages in a queue.

queue

Required
Type: string

The queue name previously passed to worker.listen.

callback

Required
Type: function
Arguments: err

A callback to be called when the worker is no longer listening on the queue.

worker.ping(callback) -> undefined

Asserts a temporary, auto-deleted queue to verify that the connection is usable.

callback

Required
Type: function
Arguments: err

A callback to be called when the ping is complete.

worker.on('data', callback) -> worker

Listens on new data on all active queues.

callback

Required
Type: function
Arguments: queue, data, done

A callback to be called with inbound data.

queue

Type: string

The queue that received the message.

data

Type: any

The parsed message data.

done

Type: callback Arguments: err

A callback you must call to acknowledge the message. If an error is passed, the message will be nacked and either placed into the dead-letter queue or re-queued, depending on your configuration.

worker.on('error', callback) -> worker

Emitted when the incoming message cannot be parsed. This event must be handled or your process will exit when it's emitted.

License

MIT © Ben Drucker