Jido.Agent.Directive.Cron (Jido v2.0.0-rc.0)

View Source

Register or update a recurring cron job for this agent.

The job is owned by the agent's id and identified within that agent by job_id. On each tick, the scheduler sends message (or signal) back to the agent via Jido.AgentServer.cast/2.

Fields

  • job_id - Logical id within the agent (for upsert/cancel). Auto-generated if nil.
  • cron - Cron expression string (e.g., " ", "@daily", "/5 ")
  • message - Signal or message to send on each tick
  • timezone - Optional timezone identifier (default: UTC)

Examples

# Every minute, send a tick signal
%Cron{cron: "* * * * *", message: tick_signal, job_id: :heartbeat}

# Daily at midnight, send a cleanup signal
%Cron{cron: "@daily", message: cleanup_signal, job_id: :daily_cleanup}

# Every 5 minutes with timezone
%Cron{cron: "*/5 * * * *", message: check_signal, job_id: :check, timezone: "America/New_York"}

Summary

Functions

Returns the Zoi schema for Cron.

Types

t()

@type t() :: %Jido.Agent.Directive.Cron{
  cron: any(),
  job_id: any(),
  message: any(),
  timezone: any()
}

Functions

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for Cron.