1.1.2 • Published 4 years ago

@essential-projects/scheduler_extension v1.1.2

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

Scheduler Extension

This is an extension for the @essential-projects/bootstrapper.

What are the goals of this project?

The goal is to provide applications that utilize the @essential-projects/bootstrapper. a way to execute functions based on a schedule.

Requirements

  • Node > 10.15.0

Setup/Installation

Install the extension and its contracts:

npm install \
  @essential-projects/scheduler_extension \
  @essential-projects/scheduler_contracts

How do I use this project?

  1. Create a Scheduler Router

    import {BaseController} from '@essential-projects/scheduler_extension';
    
    export class MySchedulerController extends BaseController {
      public initializeScheduler(): void {
        this.registerJobs();
      }
    
      private registerJobs(): void {
        this.registerJob('*/5 * * * * *', (): void => {
          console.log("I'm scheduled to run every 5 seconds!");
        });
      }
    }
  2. Register that Controller with the schedulerDiscoveryTag

    import {MySchedulerController} from './my_scheduler_controller';
    import {schedulerDiscoveryTag} from '@essential-projects/scheduler_contracts';
    
    iocContainer.register('MySchedulerController', MySchedulerController)
      .tags(schedulerDiscoveryTag)
      .singleton();
    }
  3. Register the extension to the ioc-container

    const {registerInContainer} = await import('@essential-projects/scheduler_extension/ioc_module');
    registerInContainer(iocContainer);

When starting the bootstrapper, it will now discover the extension. The extension will then discover the registered schedulers, register all the jobs and schedule their execution.

Authors/Contact information

  1. Heiko Mathes