Tutorial: Overview: flitter-agenda

Overview: flitter-agenda

Overview

flitter-agenda provides a wrapper for the Agenda scheduler. This allows jobs to be defined and scheduled programmatically, and persistently. It uses the same MongoDB database as the rest of the Flitter application.

For the most part, using flitter-agenda is identical to using vanilla Agenda. The only main difference is that jobs should be defined in individual files in a given directory (by default, app/jobs). Each of these files should export a class that extends flitter-agenda/Job. The name of a job is parsed from its file name, recursively. flitter-agenda uses the Flitter convention for sub-directory naming, meaning that sub-directories are delineated with a : character. For example, the job named auth:CleanUsers would be located in the file app/jobs/auth/CleanUsers.job.js.

_flitter.scheduler is the running instance of Agenda, so you can call any function on it like you normally would such as schedule(), every(), even define(). (See the Agenda docs.) Here, we scheduled the Log job we created to run 3 seconds after the schedule() function is called, and passed it a message.