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
impl ReplicationRuntimeHandle
Sourcepub fn coordinator(&self) -> &Arc<ReplicationCoordinator> ⓘ
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.
Sourcepub async fn dispatch(&self, event: Inbound) -> Result<(), AdapterError>
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.
Sourcepub fn try_dispatch(&self, event: Inbound) -> Result<(), Inbound>
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.
Sourcepub async fn cancel(&self)
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.
Sourcepub fn is_stopped(&self) -> bool
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
impl Drop for ReplicationRuntimeHandle
Source§fn drop(&mut self)
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.