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

orkid

v0.11.0

Published

Reliable and modern Redis-Streams based task queue for Node.js

Downloads

314

Readme

NPM version Build Status Code Coverage Dependencies Dev Dependencies Required Node License

Reliable and modern Redis-Streams based task queue for Node.js.


Screenshot

screenshot


Table of Contents


Features

  • [x] Orkid lets Redis do the heavy lifting with Redis-Streams.
  • [x] Adjustable concurrency per consumer instance for scaling task processing. See example code. See example code.
  • [x] Job timeouts and retries. All configurable per consumer. See example code.
  • [x] Task Deduplication. If a task is already waiting in the queue, it can be configured to avoid queueing the same task again. (Useful for operations like posting database record updates to elasticsearch for re-indexing. Deduplication is a common pattern here to avoid unnecessary updates). See example code.
  • [x] Add tasks in bulk in one call. The producer will handle chunking and optimize round-trips to redis using pipelining.
  • [x] Monitoring and management UI for better visibility.
  • [ ] Rate-limiting workers. (work in progress)

Requirements

  • Node.js >= 10
  • Redis >= 5

👏 Important: Redis-Streams feature is not available before Redis version 5.


Install

npm install orkid --save

Examples

Basic example of producing and consuming tasks:

Producing tasks:

const { Producer } = require('orkid');

// `basic` is the queue name here
//  We'll use the same name in the consumer to process this task
const producer = new Producer('basic');

async function addTasks() {
  for (let i = 0; i < 10; i++) {
    console.log('Adding task ', i);
    await producer.addTask(i);
  }
}

addTasks()
  .then(() => {
    console.log('Done');
    process.exit(); // To disconnect from redis
  })
  .catch(e => console.error(e));

Consuming tasks:

const { Consumer } = require('orkid');

// Worker Function
async function workerFn(data, metadata) {
  let result;
  /*
    Do operation on `data` here
    and store the result in `result` variable

    Anything you return from this function will
    be saved in redis and can be viewed in the Orkid UI.

    Returning nothing is fine too.

    Throwing error will mark the job as failed,
    which can be retried too.
  */

  console.log('Task done!');
  return result;
}

// Consume task from the `basic` queue
const consumer = new Consumer('basic', workerFn);

// Start processing tasks!
// Important: Until you call this method, orkid consumer will do nothing.
consumer.start();

👏 More examples are available in the ./examples directory, including how to do task de-duplication, retry on failure, timeout etc. 👏


API Documentation

API Documentation is available here.


Monitoring and Management UI/Admin Panel

screenshot screenshot

You need to run orkid-ui separately for the dashboard. Detail instructions on how to run orkid-ui locally or in production using docker/docker-compose can be found here: https://github.com/mugli/orkid-ui#running-locally


Task/job life-cycle

[TODO: Add a flowchart here]


FAQ


Maintainer(s)


License

MIT


Related Projects

  • orkid-ui: Dashboard to monitor and manage Orkid task queue.
  • orkid-api: GraphQL API to monitor and manage Orkid task queue (used internally by orkid-ui).