The tulip.pkg.cron module exports the cron package.


  • tulip.pkg.database
  • tulip.pkg.mqueue


  • allowed_jobs: array of string = if set, only those jobs will be allowed.
  • default_max_age: integer|nil = if set, use as default max age for the jobs messages, defaults to 24 hours.
  • default_max_attempts: integer|nil = if set, use as default maximum number of attempts to process a job's message, defaults to 1.
  • jobs: dictionary|nil = if set, list of jobs to schedule at startup. The key is the job name, and the value is the same as the t table that can be passed in App:schedule.

#API Extensions

Registering this package provides the following method and field extensions.

#ok, err = App:schedule(job[, conn[, t]])

Schedule or unschedule a job.


  • job: string = name of the job
  • conn: connection|nil = optional database connection to use
  • t: string|table|nil = if nil, unschedule the job. If it is a string, it is the cron schedule, if it is a table, it is a table with the following fields:
    • t.schedule: string = the cron schedule
    • t.max_attempts: number|nil = maximum number of attempts
    • t.max_age: number|nil = number of seconds to process message
    • t.command: string|nil = if set, the scheduled job will run this SQL command instead of enqueueing a message.
    • t.payload: table|function|nil = if set, will be the message's payload. If it is a function, it is called with the job name, connection and config table and its first return value is used as payload.


  • ok: boolean = true on success
  • err: Error|nil = error message if ok is falsy.

Back to index

About this wiki

commit 3ebfbd288b8e5c95fdf8ce2027a0e94cfa1c8976
Author: Martin Angers <martin.n.angers@gmail.com>
Date:   2021-02-25T14:07:12-05:00

Update to reflect Request:validate_body
Clone this wiki
https://git.sr.ht/~mna/tulip-wiki (read-only)
git@git.sr.ht:~mna/tulip-wiki (read/write)