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

@zingle/redis-queue

v0.0.1

Published

async queue backed by Redis

Downloads

2

Readme

Redis implementation of the AsyncQueue interface, which in turn is just an async push and shift. Provides reliable delivery with automatic recovery in case of failure.

Basic Usage

const key = "awesome-queue";
const RedisQueue = require("@zingle/redis-queue");
const queue = RedisQueue({key});

(async () => {
    let value;

    await queue.push("foo");
    await queue.push("bar");

    do {
        value = await queue.shift();
        console.log(value);
    } while (value !== undefined);
})().catch(console.error);

Reliable Delivery

Putting data into the queue is an atomic operation and is thus intrinsically reliable. Pulling data out of the queue can be an atomic operation, but to ensure reliable processing, a callback function can be used which must complete successfully before the data is removed permanently from the queue.

When a callback is passed to the shift method, a transaction is written which can be used to recover the data in case of failure during processing. The queue treats un-exceptional results as delivery and exceptional results as temporary failures.

After making several failed attempts to deliver data, the failure becomes permanent. Data which cannot be delivered will be written to a Redis LIST specified by the dead_key option, if configured.

When a queue starts up it will execute recovery before data deliver starts. Any queued data which was left in an unfinished transaction will be atomically put back into the queue for processing.

Quick Overview

  • push is atomic and reliable
  • shift without handler is atomic and reliable
  • shift with handler ends up in one of three states
    • handled successfully without exception
    • in unfinished transaction after system failure
    • in dead drop after permanent failure
  • recovery will re-queue any unfinished transactions

Duplicate Delivery

It's possible for duplicate delivery to occur when there are multiple processors operating on the same queue. This can happen if processing takes a long time in one worker. Another worker will assume the previous worker has permanently hung and will never complete, and so it will "recover" that data by putting it back into the queue.

TODO:

  • notes on timeouts
  • implement/test timeouts