Skip to main content
Cloacina Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Schedule

cloacina::models::schedule Rust

Unified schedule management module for both cron and trigger-based workflow execution.

This module provides domain structures for the unified schedules and schedule_executions tables, replacing the separate cron and trigger models.

Structs

cloacina::models::schedule::Schedule

pub

Derives: Debug, Clone, Serialize, Deserialize

Represents a unified schedule record (domain type).

Contains fields for both cron and trigger schedules. Fields irrelevant to the schedule_type will be None.

Fields

Name Type Description
id UniversalUuid
schedule_type String
workflow_name String
enabled UniversalBool
cron_expression Option < String >
timezone Option < String >
catchup_policy Option < String >
start_date Option < UniversalTimestamp >
end_date Option < UniversalTimestamp >
trigger_name Option < String >
poll_interval_ms Option < i32 >
allow_concurrent Option < UniversalBool >
next_run_at Option < UniversalTimestamp >
last_run_at Option < UniversalTimestamp >
last_poll_at Option < UniversalTimestamp >
created_at UniversalTimestamp
updated_at UniversalTimestamp

Methods

get_type pub
fn get_type (& self) -> ScheduleType

Returns the schedule type as an enum.

Source
    pub fn get_type(&self) -> ScheduleType {
        ScheduleType::from(self.schedule_type.as_str())
    }
is_cron pub
fn is_cron (& self) -> bool

Returns true if this is a cron schedule.

Source
    pub fn is_cron(&self) -> bool {
        self.get_type() == ScheduleType::Cron
    }
is_trigger pub
fn is_trigger (& self) -> bool

Returns true if this is a trigger schedule.

Source
    pub fn is_trigger(&self) -> bool {
        self.get_type() == ScheduleType::Trigger
    }
is_enabled pub
fn is_enabled (& self) -> bool

Returns true if the schedule is enabled.

Source
    pub fn is_enabled(&self) -> bool {
        self.enabled.is_true()
    }
poll_interval pub
fn poll_interval (& self) -> Option < Duration >

Returns the poll interval as a Duration (trigger schedules only).

Source
    pub fn poll_interval(&self) -> Option<Duration> {
        self.poll_interval_ms
            .map(|ms| Duration::from_millis(ms as u64))
    }
allows_concurrent pub
fn allows_concurrent (& self) -> bool

Returns true if concurrent executions are allowed (trigger schedules only).

Source
    pub fn allows_concurrent(&self) -> bool {
        self.allow_concurrent
            .as_ref()
            .map(|b| b.is_true())
            .unwrap_or(false)
    }

cloacina::models::schedule::NewSchedule

pub

Derives: Debug, Clone, Serialize, Deserialize

Structure for creating new schedule records.

Fields

Name Type Description
schedule_type String
workflow_name String
enabled Option < UniversalBool >
cron_expression Option < String >
timezone Option < String >
catchup_policy Option < String >
start_date Option < UniversalTimestamp >
end_date Option < UniversalTimestamp >
trigger_name Option < String >
poll_interval_ms Option < i32 >
allow_concurrent Option < UniversalBool >
next_run_at Option < UniversalTimestamp >

Methods

cron pub
fn cron (workflow_name : & str , cron_expression : & str , next_run_at : UniversalTimestamp ,) -> Self

Create a new cron schedule.

Source
    pub fn cron(
        workflow_name: &str,
        cron_expression: &str,
        next_run_at: UniversalTimestamp,
    ) -> Self {
        Self {
            schedule_type: "cron".to_string(),
            workflow_name: workflow_name.to_string(),
            enabled: Some(UniversalBool::new(true)),
            cron_expression: Some(cron_expression.to_string()),
            timezone: Some("UTC".to_string()),
            catchup_policy: Some("skip".to_string()),
            start_date: None,
            end_date: None,
            trigger_name: None,
            poll_interval_ms: None,
            allow_concurrent: None,
            next_run_at: Some(next_run_at),
        }
    }
trigger pub
fn trigger (trigger_name : & str , workflow_name : & str , poll_interval : Duration) -> Self

Create a new trigger schedule.

Source
    pub fn trigger(trigger_name: &str, workflow_name: &str, poll_interval: Duration) -> Self {
        Self {
            schedule_type: "trigger".to_string(),
            workflow_name: workflow_name.to_string(),
            enabled: Some(UniversalBool::new(true)),
            cron_expression: None,
            timezone: None,
            catchup_policy: None,
            start_date: None,
            end_date: None,
            trigger_name: Some(trigger_name.to_string()),
            poll_interval_ms: Some(poll_interval.as_millis() as i32),
            allow_concurrent: Some(UniversalBool::new(false)),
            next_run_at: None,
        }
    }

cloacina::models::schedule::ScheduleExecution

pub

Derives: Debug, Clone, Serialize, Deserialize

Represents a schedule execution record (domain type).

Fields

Name Type Description
id UniversalUuid
schedule_id UniversalUuid
pipeline_execution_id Option < UniversalUuid >
scheduled_time Option < UniversalTimestamp >
claimed_at Option < UniversalTimestamp >
context_hash Option < String >
started_at UniversalTimestamp
completed_at Option < UniversalTimestamp >
created_at UniversalTimestamp
updated_at UniversalTimestamp

cloacina::models::schedule::NewScheduleExecution

pub

Derives: Debug, Clone, Serialize, Deserialize

Structure for creating new schedule execution records.

Fields

Name Type Description
schedule_id UniversalUuid
pipeline_execution_id Option < UniversalUuid >
scheduled_time Option < UniversalTimestamp >
claimed_at Option < UniversalTimestamp >
context_hash Option < String >

Enums

cloacina::models::schedule::CatchupPolicy pub

Enum representing the different catchup policies for missed cron executions.

Variants

  • Skip
  • RunAll

cloacina::models::schedule::ScheduleType pub

The type of schedule — determines which fields are relevant.

Variants

  • Cron
  • Trigger