0.0
No release in over 3 years
Schedules and manages delayed, async and cron style tasks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 1.9
>= 1.3.11
>= 1.4.9
>= 1.4.17
>= 1.2.1
 Project Readme

lex-scheduler

Cron and interval task scheduling for LegionIO. Reads schedule definitions from the database, determines which tasks are due, and publishes them to the message bus. Uses a distributed lock via legion-cache to ensure only one node runs the scheduler at a time.

This is a core LEX required for scheduled task execution.

Installation

gem install lex-scheduler

Usage

Schedules are stored in the database with either a cron expression or an interval:

  • Interval: Run every N seconds since the last completion (integer)
  • Cron: Run at specific times using standard cron syntax (*/5 * * * *) or human-readable expressions (every day at noon) parsed by fugit

Schedules can also carry a transformation ERB template. If present, the scheduled task is routed through lex-transformer before execution.

Adding Schedules

Insert records into the schedules table via legion-data:

Legion::Extensions::Scheduler::Data::Models::Schedule.insert(
  function_id: 42,
  interval:    300,          # run every 5 minutes
  active:      1,
  last_run:    Time.now,
  payload:     '{}'
)

Standalone Client

Legion::Extensions::Scheduler::Client provides access to the Schedule runner:

require 'legion/extensions/scheduler/client'
client = Legion::Extensions::Scheduler::Client.new

Accepts optional data_model: and fugit: kwargs for injection (useful in tests).

Requirements

  • Ruby >= 3.4
  • LegionIO framework
  • legion-data (schedule persistence)
  • legion-cache (distributed scheduler lock)
  • fugit >= 1.9 (cron expression parsing)

License

MIT