0.3.4 • Published 6 years ago

node-queue-manager v0.3.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Node Queue Manager

A simple node queue manager.

This project aims to make the queue management in node enviroment simpler.

Providers

TypeDescription
bullBull
syncUseful to local development

Example

All the examples are in Typescript, but this project also works with JS.

Generating queue

You need generate a queue file.

import { QueueAbstract } from 'node-queue-manager';

export class ExampleQueue extends QueueAbstract {

  public getName(): string {
    return 'example.queue';
  }

  public getConcurrency(): number { //This method is optional
    return 3; // Set the queue concurrency
  }

  public async run(data: string) {
    // My code here
    console.log('Running example queue');
  }
}

To generate a queue:

import { QueueManager } from 'node-queue-manager';
import { ExampleQueue } from './example.queue';

const queueManager = new QueueManager({
  redis: {
    host: 'redis-host',
    port: 6379,
  },
  type: 'Bull',
});

const exampleQueue: ExampleQueue = new ExampleQueue();
renderQueue.setData({
  prop01: 'Test',
  prop02: 'Test 02'
});
const exampleQueue = await queueManager.publish(exampleQueue);

Consuming queue

Consuming only one queue:

import { QueueManager } from 'node-queue-manager';
import { ExampleQueue } from './example.queue';

const queueManager = new QueueManager({
  redis: {
    host: 'redis-host',
    port: 6379,
  },
  type: 'Bull',
});

await queueManager.listen(new ExampleQueue());

Consuming multiple queues:

import { QueueManager } from 'node-queue-manager';
import { ExampleQueue } from './example.queue';
import { Example02Queue } from './example.02.queue';

const queueManager = new QueueManager({
  redis: {
    host: 'redis-host',
    port: 6379,
  },
  type: 'Bull',
});

await queueManager.listenAll([
  new ExampleQueue(),
  new Example02Queue(),
]);
0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.0.1

6 years ago