pub struct FallbackCoordinator { /* private fields */ }Expand description
coordinates fallback operations across multiple components with acknowledgement.
this is meant to be used together with crate::task_manager::TaskManager,
as it allows triggering a fallback event (via CancellationToken) and waiting
until all registered components have completed their cleanup.
in summary, every time we spawn a fallback-relevant task inside the manager, we MUST:
- call
FallbackCoordinator::registerat task bootstrap - call [
FallbackCoordinator::done] at task completion
when a fallback trigger arrives to the main status loop, we MUST call
[FallbackCoordinator::trigger_and_wait] to wait for all registered components to complete
their cleanup before re-initializing them under the new upstream server.
finally, a new FallbackCoordinator must be instantiated for the next fallback cycle.
Implementations§
Source§impl FallbackCoordinator
impl FallbackCoordinator
pub fn new() -> Self
Sourcepub fn register(&self) -> FallbackHandler
pub fn register(&self) -> FallbackHandler
register a component that will participate in fallback coordination
returns a FallbackHandler that must be called when the component is done
Sourcepub fn token(&self) -> CancellationToken
pub fn token(&self) -> CancellationToken
get the cancellation token that signals fallback
Sourcepub async fn trigger_fallback_and_wait(&self)
pub async fn trigger_fallback_and_wait(&self)
trigger fallback and wait for all registered components to acknowledge
Trait Implementations§
Source§impl Clone for FallbackCoordinator
impl Clone for FallbackCoordinator
Source§fn clone(&self) -> FallbackCoordinator
fn clone(&self) -> FallbackCoordinator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more