hypercall/runtime/
api_status_boundary.rs1use hypercall_api::runtime_status::{
2 ReadinessGate, StandbyPromoteOutcome, StandbyPromoter, StandbyReplayProgress,
3 StartupProgressReader, StartupProgressSnapshot,
4};
5
6impl StandbyReplayProgress for crate::nats::replay_loop::ReplayProgress {
7 fn commands_replayed(&self) -> u64 {
8 self.commands_replayed()
9 }
10
11 fn is_caught_up(&self) -> bool {
12 self.is_caught_up()
13 }
14
15 fn replay_cursor_seq(&self) -> Option<i64> {
16 self.replay_cursor_seq()
17 }
18
19 fn latest_stream_seq(&self) -> Option<u64> {
20 self.latest_stream_seq()
21 }
22
23 fn stream_lag(&self) -> Option<u64> {
24 self.stream_lag()
25 }
26
27 fn last_replayed_seq(&self) -> Option<i64> {
28 self.last_replayed_seq()
29 }
30
31 fn last_replay_unix_ms(&self) -> Option<u64> {
32 self.last_replay_unix_ms()
33 }
34}
35
36impl StartupProgressReader for crate::runtime::integrated::StartupProgress {
37 fn snapshot(&self) -> StartupProgressSnapshot {
38 let snapshot = self.snapshot();
39 StartupProgressSnapshot {
40 phase: snapshot.phase,
41 counter: snapshot.counter,
42 last_progress_unix_ms: snapshot.last_progress_unix_ms,
43 last_progress_age_ms: snapshot.last_progress_age_ms,
44 }
45 }
46}
47
48impl ReadinessGate for crate::readiness::ReadinessRegistry {
49 fn reports(&self) -> Vec<hypercall_api::models::ReadinessComponentReport> {
50 self.reports()
51 .into_iter()
52 .map(|report| hypercall_api::models::ReadinessComponentReport {
53 name: report.name,
54 ready: report.ready,
55 detail: report.detail,
56 })
57 .collect()
58 }
59
60 fn all_ready(&self) -> bool {
61 self.all_ready()
62 }
63}
64
65#[async_trait::async_trait]
66impl StandbyPromoter for crate::runtime::standby::StandbyController {
67 async fn promote(&self) -> StandbyPromoteOutcome {
68 match self.promote().await {
69 crate::runtime::standby::PromoteResult::Promoted { queued_orders } => {
70 StandbyPromoteOutcome::Promoted { queued_orders }
71 }
72 crate::runtime::standby::PromoteResult::AlreadyActive => {
73 StandbyPromoteOutcome::AlreadyActive
74 }
75 }
76 }
77}