Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

brokkr-models::models::work_orders Rust

Structs

brokkr-models::models::work_orders::WorkOrder

pub

Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents an active work order in the queue.

Fields

NameTypeDescription
idUuidUnique identifier for the work order.
created_atDateTime < Utc >Timestamp when the work order was created.
updated_atDateTime < Utc >Timestamp when the work order was last updated.
work_typeStringType of work (e.g., “build”, “test”, “backup”).
yaml_contentStringMulti-document YAML content (e.g., Build + WorkOrder definitions).
statusStringQueue status: PENDING, CLAIMED, or RETRY_PENDING.
claimed_byOption < Uuid >ID of the agent that claimed this work order (if any).
claimed_atOption < DateTime < Utc > >Timestamp when the work order was claimed.
claim_timeout_secondsi32Seconds before a claimed work order is considered stale.
max_retriesi32Maximum number of retry attempts.
retry_counti32Current retry count.
backoff_secondsi32Base backoff seconds for exponential retry calculation.
next_retry_afterOption < DateTime < Utc > >Timestamp when RETRY_PENDING work order becomes PENDING again.
last_errorOption < String >Most recent error message from failed execution attempt.
last_error_atOption < DateTime < Utc > >Timestamp of the most recent failure.

brokkr-models::models::work_orders::NewWorkOrder

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema

Represents a new work order to be inserted into the database.

Fields

NameTypeDescription
work_typeStringType of work (e.g., “build”, “test”, “backup”).
yaml_contentStringMulti-document YAML content.
max_retriesi32Maximum number of retry attempts.
backoff_secondsi32Base backoff seconds for exponential retry calculation.
claim_timeout_secondsi32Seconds before a claimed work order is considered stale.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (work_type : String , yaml_content : String , max_retries : Option < i32 > , backoff_seconds : Option < i32 > , claim_timeout_seconds : Option < i32 > ,) -> Result < Self , String >
}

Creates a new NewWorkOrder instance with validation.

Parameters:

NameTypeDescription
work_type-Type of work (e.g., “build”, “test”).
yaml_content-Multi-document YAML content.
max_retries-Maximum retry attempts (optional, defaults to 3).
backoff_seconds-Base backoff for retries (optional, defaults to 60).
claim_timeout_seconds-Claim timeout (optional, defaults to 3600).

Returns:

Returns Ok(NewWorkOrder) if valid, otherwise Err with validation error.

Source
#![allow(unused)]
fn main() {
    pub fn new(
        work_type: String,
        yaml_content: String,
        max_retries: Option<i32>,
        backoff_seconds: Option<i32>,
        claim_timeout_seconds: Option<i32>,
    ) -> Result<Self, String> {
        // Validate work_type
        if work_type.trim().is_empty() {
            return Err("Work type cannot be empty".to_string());
        }

        // Validate yaml_content
        if yaml_content.trim().is_empty() {
            return Err("YAML content cannot be empty".to_string());
        }

        let max_retries = max_retries.unwrap_or(3);
        let backoff_seconds = backoff_seconds.unwrap_or(60);
        let claim_timeout_seconds = claim_timeout_seconds.unwrap_or(3600);

        if max_retries < 0 {
            return Err("max_retries must be non-negative".to_string());
        }

        if backoff_seconds <= 0 {
            return Err("backoff_seconds must be positive".to_string());
        }

        if claim_timeout_seconds <= 0 {
            return Err("claim_timeout_seconds must be positive".to_string());
        }

        Ok(NewWorkOrder {
            work_type,
            yaml_content,
            max_retries,
            backoff_seconds,
            claim_timeout_seconds,
        })
    }
}

brokkr-models::models::work_orders::WorkOrderLog

pub

Derives: Queryable, Selectable, Identifiable, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents a completed work order in the audit log.

Fields

NameTypeDescription
idUuidOriginal work order ID.
work_typeStringType of work.
created_atDateTime < Utc >Timestamp when the work order was created.
claimed_atOption < DateTime < Utc > >Timestamp when the work order was claimed.
completed_atDateTime < Utc >Timestamp when the work order completed.
claimed_byOption < Uuid >ID of the agent that executed this work order.
successboolWhether the work completed successfully.
retries_attemptedi32Number of retry attempts before completion.
result_messageOption < String >Result message (image digest on success, error details on failure).
yaml_contentStringOriginal YAML content for debugging/reconstruction.

brokkr-models::models::work_orders::NewWorkOrderLog

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize

Represents a new work order log entry to be inserted.

Fields

NameTypeDescription
idUuidOriginal work order ID.
work_typeStringType of work.
created_atDateTime < Utc >Timestamp when the work order was created.
claimed_atOption < DateTime < Utc > >Timestamp when the work order was claimed.
claimed_byOption < Uuid >ID of the agent that executed this work order.
successboolWhether the work completed successfully.
retries_attemptedi32Number of retry attempts before completion.
result_messageOption < String >Result message.
yaml_contentStringOriginal YAML content.

Methods

from_work_order pub
#![allow(unused)]
fn main() {
fn from_work_order (work_order : & WorkOrder , success : bool , result_message : Option < String > ,) -> Self
}

Creates a new log entry from a completed work order.

Source
#![allow(unused)]
fn main() {
    pub fn from_work_order(
        work_order: &WorkOrder,
        success: bool,
        result_message: Option<String>,
    ) -> Self {
        NewWorkOrderLog {
            id: work_order.id,
            work_type: work_order.work_type.clone(),
            created_at: work_order.created_at,
            claimed_at: work_order.claimed_at,
            claimed_by: work_order.claimed_by,
            success,
            retries_attempted: work_order.retry_count,
            result_message,
            yaml_content: work_order.yaml_content.clone(),
        }
    }
}

brokkr-models::models::work_orders::WorkOrderTarget

pub

Derives: Queryable, Selectable, Identifiable, Associations, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents a work order target (agent routing).

Fields

NameTypeDescription
idUuidUnique identifier for the target entry.
work_order_idUuidID of the work order.
agent_idUuidID of the eligible agent.
created_atDateTime < Utc >Timestamp when the target was created.

brokkr-models::models::work_orders::NewWorkOrderTarget

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema

Represents a new work order target to be inserted.

Fields

NameTypeDescription
work_order_idUuidID of the work order.
agent_idUuidID of the eligible agent.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (work_order_id : Uuid , agent_id : Uuid) -> Result < Self , String >
}

Creates a new work order target.

Source
#![allow(unused)]
fn main() {
    pub fn new(work_order_id: Uuid, agent_id: Uuid) -> Result<Self, String> {
        if work_order_id.is_nil() {
            return Err("Invalid work order ID".to_string());
        }
        if agent_id.is_nil() {
            return Err("Invalid agent ID".to_string());
        }
        Ok(NewWorkOrderTarget {
            work_order_id,
            agent_id,
        })
    }
}

Functions

brokkr-models::models::work_orders::default_max_retries

private

#![allow(unused)]
fn main() {
fn default_max_retries () -> i32
}
Source
#![allow(unused)]
fn main() {
fn default_max_retries() -> i32 {
    3
}
}

brokkr-models::models::work_orders::default_backoff_seconds

private

#![allow(unused)]
fn main() {
fn default_backoff_seconds () -> i32
}
Source
#![allow(unused)]
fn main() {
fn default_backoff_seconds() -> i32 {
    60
}
}

brokkr-models::models::work_orders::default_claim_timeout_seconds

private

#![allow(unused)]
fn main() {
fn default_claim_timeout_seconds () -> i32
}
Source
#![allow(unused)]
fn main() {
fn default_claim_timeout_seconds() -> i32 {
    3600
}
}