Skip to main content

ConnectivityState

Struct ConnectivityState 

Source
pub struct ConnectivityState {
    pub is_offline: bool,
    pub check_pending: bool,
    pub poll_pending: bool,
    pub consecutive_failures: u32,
    pub consecutive_successes: u32,
    pub required_failures_to_go_offline: u32,
    pub required_successes_to_go_online: u32,
    pub offline_poll_interval_ms: u64,
}
Expand description

Tracks network connectivity status for offline detection.

This state is used to implement the freeze-and-resume workflow feature:

  • When network connectivity is lost, the pipeline enters offline mode
  • While offline, all budget-consuming operations are suspended
  • When connectivity returns, the pipeline resumes from the frozen checkpoint

§State Transitions

[Online] --(probe failed)--> [Probe Failing] --(threshold reached)--> [Offline]
[Offline] --(probe succeeded)--> [Back Online] --(orchestrator resumes)--> [Online]

§Debouncing

To prevent rapid offline/online thrashing on unstable connections:

  • Must fail N consecutive probes before entering offline mode (default: 2)
  • Must succeed 1 probe before exiting offline mode (default: 1)

Fields§

§is_offline: bool

True when we have confirmed the pipeline is in offline mode (poll loop active).

§check_pending: bool

True when an InvocationFailed{Network} event was received and we need to verify connectivity before consuming retry budget.

§poll_pending: bool

True when offline is confirmed and we are in the poll-for-reconnect loop.

§consecutive_failures: u32

Consecutive failed probes (used for debounce threshold before entering offline mode).

§consecutive_successes: u32

Consecutive successful probes (used for debounce before exiting offline mode).

§required_failures_to_go_offline: u32

How many consecutive failures before entering offline mode (default: 2).

§required_successes_to_go_online: u32

How many consecutive successes before exiting offline mode (default: 1).

§offline_poll_interval_ms: u64

Milliseconds to wait between polls while offline (default: 5000).

Implementations§

Source§

impl ConnectivityState

Source

pub fn new() -> Self

Create a new empty connectivity state (fully online, no pending checks).

Source

pub fn trigger_check(self) -> Self

Mark that a connectivity check is needed (triggered by Network error).

Source

pub fn clear_check_pending(self) -> Self

Clear the check_pending flag.

Source

pub fn on_probe_failed(self) -> Self

Record a failed connectivity probe.

Returns a new state with updated counters. If the failure threshold is reached, transitions to offline mode.

Source

pub fn on_probe_succeeded(self) -> Self

Record a successful connectivity probe.

Returns a new state with updated counters. If the success threshold is reached while offline, transitions back to online mode.

Source

pub fn reset_debounce(self) -> Self

Reset debounce counters without changing offline/online status.

Use when a transient state change should reset the debounce counters.

Source

pub const fn is_offline_mode(&self) -> bool

Returns true if we have entered offline mode (debounce threshold was met).

Source

pub const fn is_check_pending(&self) -> bool

Returns true if a connectivity check is pending.

Source

pub const fn is_poll_pending(&self) -> bool

Returns true if we are actively polling for connectivity (offline mode).

Trait Implementations§

Source§

impl Clone for ConnectivityState

Source§

fn clone(&self) -> ConnectivityState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectivityState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectivityState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ConnectivityState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ConnectivityState

Source§

fn eq(&self, other: &ConnectivityState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ConnectivityState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ConnectivityState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,