mission.scheduler
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

mission.scheduler

Getting Started

Prerequisites

Installing

Environment Variables

Create new CRON Job

import { Job, Queuable, QueueBase, QueueRepo, RedisOptions } from 'mission.scheduler';

const redisOptions: RedisOptions = { port: 6379, host: '127.0.0.1', password: '' }; //Move this config values to .env file or eenvironment variables. 

@Queuable('FirstQueue', {
    defaultJobOptions: { removeOnComplete: true, repeat: { cron: '*/5 * * * * *' } },
    redis: redisOptions,
})
export class MyFirstJob implements QueueBase<any> {
    public async run(job: Job<any>): Promise<any> {
        console.log(job);
        // Your batch job logic goes here.
        return;
    }
}

Then add the payload data to that queue.

// Use Default Job Option
QueueRepo.get('FirstQueue')
         .add({ name: 'firstjob' })
         .catch((err) => console.error(err));

// Override the Job Optoin
QueueRepo.get('FirstQueue')
         .add({ name: 'firstjob' }, { repeat: { cron: '*/2 * * * * *' } })
         .catch((err) => console.error(err));

Credits

License

Readme

Keywords

Package Sidebar

Install

npm i mission.scheduler

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.09 kB

Total Files

10

Last publish

Collaborators

  • natarajanmca11