Skip to content

NodeJS group queuing library. Requires Redis.

Notifications You must be signed in to change notification settings

Nerimity/Mimiqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mimiqueue

Free, open source NodeJS group queueing library with redis. Currently being used in https://nerimity.com (My chat app)

Features

  • Cluster Support
  • Redis Required
  • Group Queuing
  • Throttle Support (minTime)

Installation

pnpm i redis @nerimity/mimiqueue

Usage

import { createQueue, createQueueProcessor } from "@nerimity/mimiqueue";
import { createClient } from "redis";
import { setTimeout } from "timers/promises";

const redisClient = createClient({
  socket: {
    host: "127.0.0.1",
    port: 6379,
  },
});

const main = async () => {
  await redisClient.connect();

  // NOTE:
  // When running in a cluster, this needs to be ran ONCE in the main thread.
  await createQueueProcessor({
    redisClient,
  });

  const queue = createQueue({
    name: "test-queue",
    redisClient,
    minTime: 1000,
  });

  queue.add(
    async () => {
      await setTimeout(5000);
      return "done";
    },
    { groupName: "someId eg ip address" }
  );

  const status = await queue.add(
    async () => {
      await setTimeout(5000);
      return "done";
    },
    { groupName: "someId eg ip address" }
  );

  console.log(status);
};

main();

About

NodeJS group queuing library. Requires Redis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published