mj_controller/session_manager/
types.rs1use super::*;
2
3#[derive(Debug)]
4pub(super) struct ProjectionAdvancedError {
5 pub(super) event_ordinal: u64,
6}
7
8impl std::fmt::Display for ProjectionAdvancedError {
9 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 write!(
11 formatter,
12 "another projector committed relay event {} first",
13 self.event_ordinal
14 )
15 }
16}
17
18impl std::error::Error for ProjectionAdvancedError {}
19
20pub(super) fn reconnect_delay(failures: u32) -> Duration {
23 let doubling = failures.saturating_sub(1).min(u32::BITS - 1);
24 RECONNECT_INTERVAL
25 .saturating_mul(1_u32 << doubling)
26 .min(RECONNECT_BACKOFF_CEILING)
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct RelaySessionTarget {
31 pub session_id: String,
32 pub spec: CommandSpec,
33 pub worker_recovery: Option<WorkerRecoveryPlan>,
37 pub project_memory: Option<ProjectMemorySyncTarget>,
38}
39
40#[derive(Debug, Clone, PartialEq, Eq)]
41pub struct ProjectMemorySyncTarget {
42 pub canonical_root: std::path::PathBuf,
43}
44
45#[derive(Debug, Clone, PartialEq, Eq)]
49pub struct WorkerWorkspace {
50 pub target: mj_core::state::ManagedWorktreeTarget,
51 pub directory: PathBuf,
52}
53
54#[derive(Debug, Clone, PartialEq, Eq)]
55pub struct WorkerRecoveryPlan {
56 pub source_target: mj_core::state::TargetLocator,
59 pub target: Option<TargetRecoveryPlan>,
60 pub workspace: Option<WorkerWorkspace>,
61 pub liveness_probe: CommandSpec,
62 pub binary_refresh: Option<WorkerBinaryRefresh>,
66 pub launch_refresh: Option<WorkerLaunchRefreshPlan>,
69 pub restart: CommandPlan,
70}
71
72#[derive(Debug, Clone, PartialEq, Eq)]
78pub enum WorkerBinaryRefresh {
79 Prepared(WorkerBinaryRefreshPlan),
80 Deferred(DeferredWorkerBinaryRefresh),
81}
82
83#[derive(Debug, Clone, PartialEq, Eq)]
84pub struct WorkerBinaryRefreshPlan {
85 pub source: PathBuf,
86 pub installed_digest: CommandSpec,
87 pub replace: CommandPlan,
88}
89
90#[derive(Debug, Clone, PartialEq, Eq)]
94pub struct DeferredWorkerBinaryRefresh {
95 pub locator: TargetLocator,
96 pub session_id: String,
97 pub installed_digest: CommandSpec,
98}
99
100#[derive(Debug, Clone, PartialEq, Eq)]
101pub struct WorkerLaunchRefreshPlan {
102 pub expected_sha256: String,
103 pub installed_digest: CommandSpec,
104 pub replace: CommandPlan,
105}