Jido.Agent.Schedules (Jido v2.2.0)

View Source

Utilities for expanding agent-level schedule declarations.

Agent schedules are declared in use Jido.Agent, schedules: [...] and target signal types that get routed through signal_routes/1.

Schedule Formats

  • {"* * * * *", "signal.type"} - Cron expression + signal type
  • {"* * * * *", "signal.type", job_id: :my_job} - With explicit job ID
  • {"* * * * *", "signal.type", job_id: :my_job, timezone: "America/New_York"} - With timezone

Job ID Namespacing

Job IDs are namespaced as tuples: {:agent_schedule, agent_name, signal_type_or_job_id}

Summary

Types

Expanded agent schedule specification (same shape as plugin schedule specs).

Functions

Expands agent schedule declarations into schedule specs.

Returns an empty list of routes for agent schedule signal types.

Types

schedule_spec()

@type schedule_spec() :: %{
  cron_expression: String.t(),
  action: nil,
  job_id: {:agent_schedule, String.t(), term()},
  signal_type: String.t(),
  timezone: String.t()
}

Expanded agent schedule specification (same shape as plugin schedule specs).

Functions

expand_schedules(schedules, agent_name)

@spec expand_schedules(list(), String.t()) :: [schedule_spec()]

Expands agent schedule declarations into schedule specs.

Examples

iex> expand_schedules([{"* * * * *", "heartbeat.tick", job_id: :hb}], "my_agent")
[%{cron_expression: "* * * * *", action: nil, job_id: {:agent_schedule, "my_agent", :hb}, signal_type: "heartbeat.tick", timezone: "Etc/UTC"}]

schedule_routes(schedules)

@spec schedule_routes([schedule_spec()]) :: []

Returns an empty list of routes for agent schedule signal types.

Agent schedules target signal types (not action modules directly), so the user must define matching routes in signal_routes/1. No automatic routes are generated.