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)]
81pub enum WorkerBinaryRefresh {
82 Prepared(WorkerBinaryRefreshPlan),
83 Remote(RemoteWorkerBinaryRefresh),
84}
85
86#[derive(Debug, Clone, PartialEq, Eq)]
87pub struct WorkerBinaryRefreshPlan {
88 pub source: PathBuf,
89 pub installed_digest: CommandSpec,
90 pub replace: CommandPlan,
91}
92
93#[derive(Debug, Clone, PartialEq, Eq)]
97pub struct RemoteWorkerBinaryRefresh {
98 pub locator: TargetLocator,
99 pub session_id: String,
100 pub installed_digest: CommandSpec,
101}
102
103#[derive(Debug, Clone, PartialEq, Eq)]
104pub struct WorkerLaunchRefreshPlan {
105 pub expected_sha256: String,
106 pub installed_digest: CommandSpec,
107 pub replace: CommandPlan,
108}