Skip to main content

ReplicationRuntimeHandle

Struct ReplicationRuntimeHandle 

Source
pub struct ReplicationRuntimeHandle { /* private fields */ }
Expand description

Handle the spawned task produces. Holds the inbox sender so the mesh dispatcher (and the lifecycle code) can push Inbound events. cancel() sends Shutdown and awaits the task to exit cleanly. The owned ReplicationCoordinator is exposed via Self::coordinator so operators (and tests) can observe the role, drive transition_to, and read the channel metrics without going through the inbox.

Implementations§

Source§

impl ReplicationRuntimeHandle

Source

pub fn coordinator(&self) -> &Arc<ReplicationCoordinator>

The per-channel coordinator. Same Arc the runtime task uses; cloning is cheap. Operators read coordinator.role() for the current state and coordinator.metrics() for the per-channel atomic counters; tests can drive coordinator.transition_to(target, signal) to put the channel in a specific role.

Source

pub async fn dispatch(&self, event: Inbound) -> Result<(), AdapterError>

Push an inbound event into the runtime’s inbox. Errors when the runtime has already exited (drained channel). Routes catchup-critical events (Shutdown, SyncResponse, SyncNack) to the priority lane so a Heartbeat flood on the standard lane can’t starve them.

Source

pub fn try_dispatch(&self, event: Inbound) -> Result<(), Inbound>

Same as Self::dispatch but for use from non-async contexts (the mesh dispatch loop’s sync hot path). Returns the event back on full-buffer rejection so the caller can decide whether to drop, log, or block.

Source

pub async fn cancel(&self)

Send Shutdown and await the task to exit. Idempotent — subsequent calls are no-ops once the task has joined.

Uses try_send first so a wedged task with a full inbox can’t hang the caller indefinitely. On Full, the JoinHandle is aborted directly; the task exits without running the graceful Idle transition but the channel is still safely torn down.

Source

pub fn is_stopped(&self) -> bool

Returns true if the runtime has stopped (task joined). Useful for tests / observability.

R-11: this consults an explicit flag flipped after cancel()’s .await returns, not the JoinHandle slot. Without the flag, two concurrent cancel() calls could race so the loser observes task.lock().take() == None and reports is_stopped == true before the winner has finished joining.

Trait Implementations§

Source§

impl Drop for ReplicationRuntimeHandle

Source§

fn drop(&mut self)

Best-effort cleanup if a handle is dropped without an explicit cancel().await. Aborts the task synchronously so the spawned future stops driving and the dispatcher Arc the task held is released — closing the strong-reference cycle MeshNode → router → handle → task → dispatcher without requiring callers to remember the cancel sequence. The graceful Idle transition is skipped on this path; callers that need the announce/withdraw side-effects to land must still cancel().await before drop.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more