class

Autobot::Cron::Service

Inherits Reference < Object

Service for managing and executing scheduled jobs.

Jobs are persisted as JSON and executed via a fiber-based timer loop.

Constants

EXEC_TIMEOUT = 30.seconds
MAX_STORED_OUTPUT_BYTES = 32768

Cap stored exec output so it can be safely re-exported as PREV_OUTPUT on the next run without tripping E2BIG (argument list too long).

OUTPUT_TRUNCATION_NOTICE = "\n...[Output truncated due to size limit]"
RELOAD_CHECK_INTERVAL = 60.seconds

Constructors

new(store_path : Path, on_job : JobCallback | Nil = nil, on_exec : ExecCallback | Nil = nil, workspace : Path | Nil = nil, sandbox_config : String = "none")
Source

Instance methods

add_job(name : String, schedule : CronSchedule, message : String = "", deliver : Bool = false, channel : String | Nil = nil, to : String | Nil = nil, delete_after_run : Bool = false, owner : String | Nil = nil, kind : PayloadKind = PayloadKind::AgentTurn, command : String | Nil = nil) : CronJob

Add a new scheduled job.

Source
clear_all

Remove all jobs and return the count of removed jobs.

Source
compute_next_run_for(job : CronJob) : Int64 | Nil

Compute next run for a job, using last_run for interval jobs or expression for cron jobs.

Source
enable_job(job_id : String, enabled : Bool = true, owner : String | Nil = nil) : CronJob | Nil

Enable or disable a job. If owner is provided, only modifies job if it matches the owner.

Source
get_job(job_id : String, owner : String | Nil = nil) : CronJob | Nil

Find a single job by ID, optionally enforcing owner access.

Source
list_jobs(include_disabled : Bool = false, owner : String | Nil = nil) : Array(CronJob)

List all jobs (optionally including disabled ones). If owner is provided, only returns jobs owned by that owner.

Source
remove_job(job_id : String, owner : String | Nil = nil) : Bool

Remove a job by ID. If owner is provided, only removes job if it matches the owner.

Source
run_job(job_id : String, force : Bool = false) : Bool

Manually run a job.

Source
start

Start the cron service timer loop.

Source
status

Get service status.

Source
stop

Stop the cron service.

Source
update_job(job_id : String, owner : String | Nil = nil, schedule : CronSchedule | Nil = nil, message : String | Nil = nil) : CronJob | Nil

Update a job's schedule and/or message in place. Returns the updated job, or nil if not found / access denied.

Source

Nested types