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

freddy

v0.6.0

Published

Simple messaging API supporting acknowledgements and request-response

Downloads

65

Readme

Messaging API supporting acknowledgements and request-response

Build Status

Setup

Inject the appropriate logger and set up connection parameters:

Freddy = require 'freddy'
Freddy.addErrorListener(listener)
Freddy.connect('amqp://guest:guest@localhost:5672', {logger}).done (freddy) ->
  continueWith(freddy)
, (error) ->
  doSthWithError(error)

TLS connection

See http://www.squaremobius.net/amqp.node/ssl.html for available options.

sslOptions = {
  cert: fs.readFileSync('clientcert.pem'),
  key: fs.readFileSync('clientkey.pem'),
  ca: [fs.readFileSync('cacert.pem')]
}

Freddy.connect('amqps://localhost:5671', {logger, ...sslOptions}).done (freddy) ->
  continueWith(freddy)
, (error) ->
  doSthWithError(error)

Supported message queues

These message queues have been tested and are working with Freddy. Other queues can be added easily:

Delivering messages

Simple delivery

Send and forget

Sends a message to the given destination. If there is no consumer then the message stays in the queue until somebody consumes it.

  freddy.deliver destination, message

Expiring messages

Sends a message to the given destination. If nobody consumes the message in timeout seconds then the message is discarded. This is useful for showing notifications that must happen in a certain timeframe but where we don't really care if it reached the destination or not.

freddy.deliver destination, message, timeout: 5

Request delivery

Expiring messages

Sends a message to the given destination. Has a default timeout of 3 and discards the message from the queue if a response hasn't been returned in that time.

freddy.deliver destination, message, (response) ->
  # ...
, (error) ->
  # ...

Persistant messages

Sends a message to the given destination. Keeps the message in the queue if a timeout occurs.

freddy.deliver destination, message, timeout: 4, deleteOnTimeout: false, (response) ->
  # ...
, (error) ->
  # ...

Responding to messages

freddy.respondTo destination, (message, handler) ->
  if true
    handler.success(id: 5)
  else
    handler.error(error: 'something went wrong')
.done (responderHandler) ->
  doSthWith(responderHandler)

Tapping into messages

When it's necessary to receive messages but not consume them, consider tapping.

responderHandler = freddy.tapInto(pattern, callback)
  • destination refers to the destination that the message was sent to
  • Note that it is not possible to respond to the message while tapping.
  • When tapping the following wildcards are supported in the pattern :
    • # matching 0 or more words
    • * matching exactly one word

Examples:

freddy.tapInto "i.#.free", (message, handler) ->
  # ...

receives messages that are delivered to "i.want.to.break.free"

freddy.tapInto "somebody.*.love", (message, handler) ->
  # ...

receives messages that are delivered to somebody.to.love but doesn't receive messages delivered to someboy.not.to.love

Credits

freddy was originally written by Urmas Talimaa as part of SaleMove development team.

SaleMove Inc. 2012

freddy is maintained and funded by SaleMove, Inc.

The names and logos for SaleMove are trademarks of SaleMove, Inc.