@vidiemme/adonis-scheduler
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

Adonis Scheduler

npm-image license-image typescript-image

This addon adds the functionality to schedule jobs managed via databases.

Introduction

This package leverages Lucid for database job management, it can be used with all types of databases supported by Lucid (MySQL, SQLite, Postgresql, ...).
For some databases that support locking, the job lock function has been implemented so that, in case of multiple server instances, only one node takes over the job from the DB.

Installation

Install the package
npm i @vidiemme/adonis-scheduler

Configure the package
node ace configure @vidiemme/adonis-scheduler

Perform migration
node ace migration:run

Usage

Make a job handler with the command node ace make:job << job name >>.
Then you must record the list of your jobs in the map inside the file start/scheduler.ts.

e.g.:

import JobClass from 'App/Jobs/JobClass'

JobMap.set('jobName', JobClass)

The Job can work with any resource on the server.
You can also pass metadata in Json format to the handle method.

interface MyCustomInterface {
    ...
}

public async
handle(params
:
MyCustomInterface
)
{
    // your job here
}

Jobs are managed directly in DB:

  • The name field must be aligned to the names entered in the JobMap.
  • the data field is optional and can contain a json of parameters to pass to the JobHandler
  • The cron field represents how often to run the job.

Package Sidebar

Install

npm i @vidiemme/adonis-scheduler

Weekly Downloads

13

Version

1.4.1

License

Apache-2.0

Unpacked Size

33.9 kB

Total Files

40

Last publish

Collaborators

  • sergio.terrasi.vidiemme
  • stefanofioretto
  • carassaleg
  • gianluca.pisati