use super::*;
#[derive(Debug)]
pub(super) struct ProjectionAdvancedError {
pub(super) event_ordinal: u64,
}
impl std::fmt::Display for ProjectionAdvancedError {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
formatter,
"another projector committed relay event {} first",
self.event_ordinal
)
}
}
impl std::error::Error for ProjectionAdvancedError {}
pub(super) fn reconnect_delay(failures: u32) -> Duration {
let doubling = failures.saturating_sub(1).min(u32::BITS - 1);
RECONNECT_INTERVAL
.saturating_mul(1_u32 << doubling)
.min(RECONNECT_BACKOFF_CEILING)
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RelaySessionTarget {
pub session_id: String,
pub spec: CommandSpec,
pub worker_recovery: Option<WorkerRecoveryPlan>,
pub project_memory: Option<ProjectMemorySyncTarget>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProjectMemorySyncTarget {
pub canonical_root: std::path::PathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WorkerWorkspace {
pub target: mj_core::state::ManagedWorktreeTarget,
pub directory: PathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WorkerRecoveryPlan {
pub source_target: mj_core::state::TargetLocator,
pub target: Option<TargetRecoveryPlan>,
pub workspace: Option<WorkerWorkspace>,
pub liveness_probe: CommandSpec,
pub binary_refresh: Option<WorkerBinaryRefresh>,
pub launch_refresh: Option<WorkerLaunchRefreshPlan>,
pub restart: CommandPlan,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WorkerBinaryRefresh {
Prepared(WorkerBinaryRefreshPlan),
Remote(RemoteWorkerBinaryRefresh),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WorkerBinaryRefreshPlan {
pub source: PathBuf,
pub installed_digest: CommandSpec,
pub replace: CommandPlan,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RemoteWorkerBinaryRefresh {
pub locator: TargetLocator,
pub session_id: String,
pub installed_digest: CommandSpec,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WorkerLaunchRefreshPlan {
pub expected_sha256: String,
pub installed_digest: CommandSpec,
pub replace: CommandPlan,
}