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
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the work order. |
created_at | DateTime < Utc > | Timestamp when the work order was created. |
updated_at | DateTime < Utc > | Timestamp when the work order was last updated. |
work_type | String | Type of work (e.g., “build”, “test”, “backup”). |
yaml_content | String | Multi-document YAML content (e.g., Build + WorkOrder definitions). |
status | String | Queue status: PENDING, CLAIMED, or RETRY_PENDING. |
claimed_by | Option < Uuid > | ID of the agent that claimed this work order (if any). |
claimed_at | Option < DateTime < Utc > > | Timestamp when the work order was claimed. |
claim_timeout_seconds | i32 | Seconds before a claimed work order is considered stale. |
max_retries | i32 | Maximum number of retry attempts. |
retry_count | i32 | Current retry count. |
backoff_seconds | i32 | Base backoff seconds for exponential retry calculation. |
next_retry_after | Option < DateTime < Utc > > | Timestamp when RETRY_PENDING work order becomes PENDING again. |
last_error | Option < String > | Most recent error message from failed execution attempt. |
last_error_at | Option < 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
| Name | Type | Description |
|---|---|---|
work_type | String | Type of work (e.g., “build”, “test”, “backup”). |
yaml_content | String | Multi-document YAML content. |
max_retries | i32 | Maximum number of retry attempts. |
backoff_seconds | i32 | Base backoff seconds for exponential retry calculation. |
claim_timeout_seconds | i32 | Seconds 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:
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
id | Uuid | Original work order ID. |
work_type | String | Type of work. |
created_at | DateTime < Utc > | Timestamp when the work order was created. |
claimed_at | Option < DateTime < Utc > > | Timestamp when the work order was claimed. |
completed_at | DateTime < Utc > | Timestamp when the work order completed. |
claimed_by | Option < Uuid > | ID of the agent that executed this work order. |
success | bool | Whether the work completed successfully. |
retries_attempted | i32 | Number of retry attempts before completion. |
result_message | Option < String > | Result message (image digest on success, error details on failure). |
yaml_content | String | Original 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
| Name | Type | Description |
|---|---|---|
id | Uuid | Original work order ID. |
work_type | String | Type of work. |
created_at | DateTime < Utc > | Timestamp when the work order was created. |
claimed_at | Option < DateTime < Utc > > | Timestamp when the work order was claimed. |
claimed_by | Option < Uuid > | ID of the agent that executed this work order. |
success | bool | Whether the work completed successfully. |
retries_attempted | i32 | Number of retry attempts before completion. |
result_message | Option < String > | Result message. |
yaml_content | String | Original 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
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the target entry. |
work_order_id | Uuid | ID of the work order. |
agent_id | Uuid | ID of the eligible agent. |
created_at | DateTime < 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
| Name | Type | Description |
|---|---|---|
work_order_id | Uuid | ID of the work order. |
agent_id | Uuid | ID 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
}
}