alpine_protocol_sdk/
mode.rs1use std::time::Duration;
2
3use crate::session::{ControlOptions, ControlRetryPolicy, ProbeOptions};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum ClientMode {
7 Ui,
8 Automation,
9 Test,
10}
11
12impl ClientMode {
13 pub fn control_options(self) -> ControlOptions {
14 match self {
15 ClientMode::Ui => ControlOptions {
16 timeout: Some(Duration::from_millis(750)),
17 retry: Some(ControlRetryPolicy {
18 max_attempts: 1,
19 backoff_base_ms: 150,
20 backoff_max_ms: 500,
21 }),
22 allow_dangerous: false,
23 },
24 ClientMode::Automation => ControlOptions {
25 timeout: Some(Duration::from_secs(2)),
26 retry: Some(ControlRetryPolicy::default()),
27 allow_dangerous: false,
28 },
29 ClientMode::Test => ControlOptions {
30 timeout: Some(Duration::from_secs(1)),
31 retry: Some(ControlRetryPolicy {
32 max_attempts: 2,
33 backoff_base_ms: 50,
34 backoff_max_ms: 250,
35 }),
36 allow_dangerous: true,
37 },
38 }
39 }
40
41 pub fn probe_options(self) -> ProbeOptions {
42 ProbeOptions {
43 include_health: true,
44 control: self.control_options(),
45 }
46 }
47
48 pub fn log_level_hint(self) -> &'static str {
49 match self {
50 ClientMode::Ui => "warn",
51 ClientMode::Automation => "info",
52 ClientMode::Test => "debug",
53 }
54 }
55}