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 exit_record: Option<CommandSpec>,
66 pub binary_refresh: Option<WorkerBinaryRefresh>,
70 pub launch_refresh: Option<WorkerLaunchRefreshPlan>,
73 pub restart: CommandPlan,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq)]
82pub enum WorkerBinaryRefresh {
83 Prepared(WorkerBinaryRefreshPlan),
84 Deferred(DeferredWorkerBinaryRefresh),
85}
86
87#[derive(Debug, Clone, PartialEq, Eq)]
88pub struct WorkerBinaryRefreshPlan {
89 pub source: PathBuf,
90 pub installed_digest: CommandSpec,
91 pub replace: CommandPlan,
92}
93
94#[derive(Debug, Clone, PartialEq, Eq)]
98pub struct DeferredWorkerBinaryRefresh {
99 pub locator: TargetLocator,
100 pub session_id: String,
101 pub installed_digest: CommandSpec,
102}
103
104#[derive(Debug, Clone, PartialEq, Eq)]
105pub struct WorkerLaunchRefreshPlan {
106 pub expected_sha256: String,
107 pub installed_digest: CommandSpec,
108 pub replace: CommandPlan,
109}