use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LakehouseCacheFillOutcome {
Completed,
Failed,
Abandoned,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LakehouseCacheFillErrorEvent {
#[doc(hidden)]
pub code: String,
#[doc(hidden)]
pub kind: String,
#[doc(hidden)]
pub status: String,
#[doc(hidden)]
pub operation: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LakehouseCacheFillEvent {
#[doc(hidden)]
pub outcome: LakehouseCacheFillOutcome,
#[doc(hidden)]
pub bytes: Option<u64>,
#[doc(hidden)]
pub elapsed: Duration,
#[doc(hidden)]
pub cache_path_hash: String,
#[doc(hidden)]
pub stable_id_hash: String,
#[doc(hidden)]
pub file_index: Option<usize>,
#[doc(hidden)]
pub chunk_index: Option<usize>,
#[doc(hidden)]
pub error: Option<LakehouseCacheFillErrorEvent>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LakehouseCacheFillEventSnapshot {
pub outcome: &'static str,
pub bytes: Option<u64>,
pub elapsed: Duration,
pub cache_path_hash: String,
pub stable_id_hash: String,
pub file_index: Option<usize>,
pub chunk_index: Option<usize>,
pub error_code: Option<String>,
pub error_kind: Option<String>,
pub error_status: Option<String>,
pub error_operation: Option<String>,
}
impl LakehouseCacheFillOutcome {
const fn as_str(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::Failed => "failed",
Self::Abandoned => "abandoned",
}
}
}
impl From<&LakehouseCacheFillEvent> for LakehouseCacheFillEventSnapshot {
fn from(event: &LakehouseCacheFillEvent) -> Self {
Self {
outcome: event.outcome.as_str(),
bytes: event.bytes,
elapsed: event.elapsed,
cache_path_hash: event.cache_path_hash.clone(),
stable_id_hash: event.stable_id_hash.clone(),
file_index: event.file_index,
chunk_index: event.chunk_index,
error_code: event.error.as_ref().map(|error| error.code.clone()),
error_kind: event.error.as_ref().map(|error| error.kind.clone()),
error_status: event.error.as_ref().map(|error| error.status.clone()),
error_operation: event.error.as_ref().map(|error| error.operation.clone()),
}
}
}