acta_maker_sdk/ws/managed/
state.rs1use tokio::sync::watch;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum ManagedWsState {
7 Connecting,
8 Connected { connection_epoch: u64 },
9 Authenticated { connection_epoch: u64 },
10 Reconciled { connection_epoch: u64 },
11 Ready { connection_epoch: u64 },
12 Reconnecting { attempt: u64, delay_ms: u64 },
13 Closed { reason: ManagedWsTerminationReason },
14}
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17#[non_exhaustive]
18pub enum ManagedWsTerminationReason {
19 Requested,
20 ReconnectLimitReached {
21 limit: u64,
22 },
23 SessionReplaced,
24 ProtocolVersionMismatch {
25 requested_version: String,
26 server_version: String,
27 min_supported_version: String,
28 },
29 AuthenticationRejected {
30 reason: String,
31 message: Option<String>,
32 },
33 SessionPanicked,
35 UnsupportedProtocolVersion,
36}
37
38#[derive(Debug, thiserror::Error)]
39#[non_exhaustive]
40pub enum WaitUntilReadyError {
41 #[error("managed websocket terminated: {0:?}")]
42 Terminated(ManagedWsTerminationReason),
43 #[error("managed websocket state channel closed")]
44 StateChannelClosed,
45}
46
47pub(super) fn set_state(tx: &watch::Sender<ManagedWsState>, state: ManagedWsState) {
48 tx.send_replace(state);
49}