1.0.6 • Published 3 years ago

bull-di v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm version downloads size Coverage Status dependencies Status type license Code style

Installation

npm i bull-di
# or
yarn add bull-di

Example

Root File

import { loadQueues, subscribeGracefulShutdown } from 'bull-di';

loadQueues({
   queues: [TestQueue],
   redisUrl: 'redis://localhost',
   events: true, // true if it`s worker
});
subscribeGracefulShutdown();

Job File

import Bull from 'bull';
import { Queue, QueueInterface } from 'bull-di';

type IInputData = { userId: string };
type IResultData = { completedAt: Date };

@Service()
@Queue('subscription-expire')
class SubscriptionExpireQueue extends QueueInterface<IInputData, IResultData> {
   @Inject(() => EmailService)
   public emailService!: EmailService;

   public async onProcess(job: Bull.Job<IInputData>) {
      await this.emailService.subscriptionExpire(job.data.userId);

      return {
         completedAt: new Date(),
      };
   }
   public async onFailure(err: Error) {
      console.log(err);
   }

   public async onCompleted(job: Bull.Job<IInputData>, res: IResultData) {
      console.log(`Subscription-expire userId:${job.data.userId} at:${res.completedAt}`);
   }
}

export default SubscriptionExpireQueue;

License

MIT

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-beta-9

3 years ago

1.0.0-beta-8

3 years ago

1.0.0-beta-6

3 years ago

1.0.0-beta-7

3 years ago

1.0.0-beta-5

3 years ago

1.0.0-beta-4

3 years ago

1.0.0-beta-3

3 years ago

1.0.0-beta-2

3 years ago

1.0.0-beta-1

3 years ago

1.0.0-beta

3 years ago