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::diagnostic_results Rust

Diagnostic Result model for storing collected diagnostic data.

Diagnostic results contain the pod statuses, events, and log tails collected by agents in response to diagnostic requests.

Structs

brokkr-models::models::diagnostic_results::DiagnosticResult

pub

Derives: Debug, Clone, Queryable, Selectable, Identifiable, Serialize, Deserialize, ToSchema

A diagnostic result record from the database.

Fields

NameTypeDescription
idUuidUnique identifier for the diagnostic result.
request_idUuidThe diagnostic request this result belongs to.
pod_statusesStringJSON-encoded pod statuses.
eventsStringJSON-encoded Kubernetes events.
log_tailsOption < String >JSON-encoded log tails (optional).
collected_atDateTime < Utc >When the diagnostics were collected by the agent.
created_atDateTime < Utc >When the result was created in the database.

brokkr-models::models::diagnostic_results::NewDiagnosticResult

pub

Derives: Debug, Clone, Insertable, Serialize, Deserialize

A new diagnostic result to be inserted.

Fields

NameTypeDescription
request_idUuidThe diagnostic request this result belongs to.
pod_statusesStringJSON-encoded pod statuses.
eventsStringJSON-encoded Kubernetes events.
log_tailsOption < String >JSON-encoded log tails (optional).
collected_atDateTime < Utc >When the diagnostics were collected by the agent.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (request_id : Uuid , pod_statuses : String , events : String , log_tails : Option < String > , collected_at : DateTime < Utc > ,) -> Result < Self , String >
}

Creates a new diagnostic result.

Parameters:

NameTypeDescription
request_id-The diagnostic request this result belongs to.
pod_statuses-JSON-encoded pod statuses.
events-JSON-encoded Kubernetes events.
log_tails-Optional JSON-encoded log tails.
collected_at-When the diagnostics were collected.

Returns:

A Result containing the new diagnostic result or an error.

Source
#![allow(unused)]
fn main() {
    pub fn new(
        request_id: Uuid,
        pod_statuses: String,
        events: String,
        log_tails: Option<String>,
        collected_at: DateTime<Utc>,
    ) -> Result<Self, String> {
        // Validate request_id is not nil
        if request_id.is_nil() {
            return Err("Request ID cannot be nil".to_string());
        }

        // Validate pod_statuses is not empty
        if pod_statuses.is_empty() {
            return Err("Pod statuses cannot be empty".to_string());
        }

        // Validate events is not empty
        if events.is_empty() {
            return Err("Events cannot be empty".to_string());
        }

        Ok(Self {
            request_id,
            pod_statuses,
            events,
            log_tails,
            collected_at,
        })
    }
}