1.0.2 • Published 6 years ago

uber-cron v1.0.2

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

UBER CRON

npm.io npm.io npm.io npm.io

Enhanced cron job scheduling with features you didn't know you need! Based on cron: https://www.npmjs.com/package/cron

What has been added

The following functionality was implemented on top of the cron package:

  • Control the number of executions that run in parallel using the numParallelExecutions paramter.
  • Configure whether a job should be stopped if an execution error occurs.
  • Uses a provided logger object to log the following events:
    • JOB_STARTED: A job has been started
    • JOB_STOPPED: A job has been stoppped
    • JOB_EXECUTION_STARTING: The onTick method of a job is about to be executed
    • JOB_EXECUTION_FINISHED: The onTick method of a job finished successfully
    • JOB_EXECUTION_ERROR: An error occured during the execution of the job's onTick method
    • REACHED_MAX_PARALLEL_EXECUTIONS: The maximum number of parallel job executions has been reached (the request to start another job execution has been ignored)

Installation

Installation is straight forward with npm:

npm i uber-cron

Examples

const cronJob = new UberCron('simpleJob', {
  cronTime: '*/1 * * * * *',
  start: true,
  logger: null,
  onTick: () => console.log(`Job being executed right now!`),
});

setTimeout(() => cronJob.stop(), 3500);

/**
OUTPUT:

root@uber-cron:/app# npm run start
> uber-cron@1.0.0 start /app
> ts-node --project tsconfig.json example/index.ts

Job being executed right now!
Job being executed right now!
Job being executed right now!
 */

API Documentation

The full API documentation can be found here: https://decentro-gmbh.github.io/uber-cron/

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago