1.1.0 β€’ Published 11 months ago

workerpool-redis v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

✨ workerpool-redis ✨

Workerpool on steroids with Redis. Queue persistence, automatic retry.

Features

  • 🐣 - Easy to use
  • ♾️ - Retry queues automatically
  • πŸ“ - Persist queues between restarts and crashes
  • πŸ’» - Runs in the browser and on Node.js
  • πŸ’… - Dynamically offloads functions to a worker
  • πŸ”₯ - Handles crashed workers
  • βœ… - Module written in TypeScript

Why

It can happen that our application restarts or crashes while jobs are in progress with workerpool. This library allows for persistence so that these jobs are not lost and can be resumed.

Install

Install via yarn

yarn add workerpool-redis

Configure Redis

Add the Redis environment variable.

If you have a password on your Redis:

// .env
REDIS_URL=redis://:password@localhost:6379

If you don't have a password on your Redis:

// .env
REDIS_URL=redis://localhost:6379

Configure your queues

Create a queue named "testing".

import { Queue } from "workerpool-redis";

const testingQueue = new Queue("testing", (foo, arg2) => {
  // your code goes here

  console.log(foo); // will output "bar"

  return "ghostlexly";
});

Add a job to your queue

Add a job

testingQueue.add(["bar", "EDF-ARGUMENT2"]);

onComplete

Trigger a function when the job is complete

import { Queue } from "workerpool-redis";

const onComplete = (result) => {
  // do something with the results..
  console.log(result); // will output "ghostlexly"
};

const testingQueue = new Queue(
  "testing",
  () => {
    // your code goes here
    return "ghostlexly";
  },
  {
    retryInMinutes: 1, // retry this job in 1 minute if the job is still not completed
    onComplete: onComplete,
  }
);
1.1.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago