Schedules

Status: [Designed] -- Area 2 of the Grove language. Syntax and semantics are defined; implementation is in progress.

Schedules start workflows on a recurring basis using cron expressions. Where triggers react to domain events, schedules react to time -- running batch jobs, sending periodic reports, performing maintenance tasks, or polling external systems at fixed intervals.

Prerequisites: Workflows Overview, Concepts Overview. What you'll learn: How to declare cron-based schedules, map static inputs to workflows, and understand schedule execution semantics.

Declaring a Schedule

A schedule binds a cron expression to a workflow:

schedule daily_reconciliation {
  when "0 2 * * *"
  start reconcile_payments v1 {
    run_type: "daily"
  }
}

The declaration has three parts:

  1. Name -- daily_reconciliation. A unique name within the module.
  2. When clause -- when "0 2 * * *". A cron expression that defines the schedule.
  3. Start block -- start reconcile_payments v1 { ... }. The workflow to start and its input mappings.

Cron Expressions

The when clause accepts standard five-field cron expressions:

minute  hour  day-of-month  month  day-of-week
  0      2        *           *        *
FieldValuesSpecial Characters
Minute0-59, - * /
Hour0-23, - * /
Day of month1-31, - * /
Month1-12, - * /
Day of week0-6 (0 = Sunday), - * /

Examples

ExpressionDescription
"0 * * * *"Every hour, on the hour
"*/15 * * * *"Every 15 minutes
"0 2 * * *"Daily at 2:00 AM
"0 9 * * 1"Every Monday at 9:00 AM
"0 0 1 * *"First day of every month at midnight
"0 8,17 * * 1-5"Weekdays at 8:00 AM and 5:00 PM

Field Mappings

The start block provides static input values to the workflow. Since schedules are time-based (not event-based), there is no event root object. Mappings use literal values:

schedule weekly_report {
  when "0 9 * * 1"
  start generate_report v1 {
    report_type: "weekly_summary"
    lookback_days: 7
    format: "pdf"
  }
}

The workflow receives these values as its input every time the schedule fires.

Execution Semantics

Multiple Schedules

A module can declare any number of schedules:

schedule hourly_sync {
  when "0 * * * *"
  start sync_inventory v1 {
    source: "warehouse"
  }
}

schedule daily_cleanup {
  when "0 3 * * *"
  start cleanup_expired_sessions v1 {
    max_age_days: 30
  }
}

schedule monthly_billing {
  when "0 0 1 * *"
  start generate_invoices v1 {
    billing_period: "monthly"
  }
}

Schedules vs. Triggers

ConcernTriggerSchedule
ActivationDomain event emittedCron tick
Input sourceEvent fields and metadataStatic literal values
FrequencyPer eventFixed time intervals
Use caseReactive orchestrationBatch jobs, periodic tasks

Both triggers and schedules start the same kind of workflows. The difference is only in what initiates the execution and what data is available as input.

See Also