pub struct EpochFencedReload { /* private fields */ }Expand description
Orchestrator for an atomic plugin reload — implements the proposal’s §11.2 epoch-fenced cutover.
The reload protocol:
- The host calls
EpochFencedReload::begin_drainon the old plugin’s lifecycle. The state advancesActive → Draining. New operations no longer capture the old plugin; in-flight ops that already captured anArc<dyn ScalarPluginFn>continue against the old instance. - The host invokes the load path for the new plugin and walks
its lifecycle
Loaded → Linked → Initialized → Active. - The host calls
EpochFencedReload::wait_for_drain, pollingArc::strong_counton the old plugin’s lifecycle. When the only outstanding reference is the framework’s bookkeepingArc, every in-flight operation against the old plugin has completed. - The host advances the old plugin’s lifecycle to
RemovedviaEpochFencedReload::finalize.
The driver is decoupled from per-kind reload discipline (per proposal §11.2.1) — that lives in the host’s storage / index / background-job specific code. This driver provides the general state-machine orchestration.
EpochFencedReload is intentionally synchronous (no async fn)
so it can be called from any context. For long-drain scenarios
(e.g., 10s wall-clock queries against a storage backend), the
host wraps the polling loop in its own async runtime.
Implementations§
Source§impl EpochFencedReload
impl EpochFencedReload
Sourcepub fn new(old: Arc<PluginLifecycle>) -> Self
pub fn new(old: Arc<PluginLifecycle>) -> Self
Construct a driver for an old-plugin lifecycle.
Sourcepub fn begin_drain(&self) -> Result<(), DrainError>
pub fn begin_drain(&self) -> Result<(), DrainError>
Begin draining the old plugin. Advances state Active → Draining.
§Errors
Returns Err if the old plugin is not in Active state — the
caller can choose to retry or bail out depending on policy.
Sourcepub fn wait_for_drain(
&self,
threshold: usize,
poll_interval: Duration,
max_wait: Duration,
) -> Result<(), DrainError>
pub fn wait_for_drain( &self, threshold: usize, poll_interval: Duration, max_wait: Duration, ) -> Result<(), DrainError>
Wait until the old plugin has been fully drained.
Polls Arc::strong_count(&self.old) with the supplied poll
interval. Returns when the count drops to threshold (the
number of bookkeeping Arcs the framework holds), or
Err(DrainError::Timeout) if max_wait elapses first.
threshold is typically 1 (just the framework’s own
EpochFencedReload::old Arc); pass 2 if the host also keeps
a side reference for diagnostics.
§Errors
Returns DrainError::Timeout if the strong-count doesn’t
drop to threshold within max_wait.
Sourcepub fn finalize(&self)
pub fn finalize(&self)
Finalize the drain — advance to Removed.
Typically called only after Self::wait_for_drain succeeds.
Safe to call multiple times (idempotent at Removed).
Sourcepub fn old_lifecycle(&self) -> &Arc<PluginLifecycle> ⓘ
pub fn old_lifecycle(&self) -> &Arc<PluginLifecycle> ⓘ
Shared access to the old plugin’s lifecycle (e.g., for observability hooks reading the current state).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EpochFencedReload
impl RefUnwindSafe for EpochFencedReload
impl Send for EpochFencedReload
impl Sync for EpochFencedReload
impl Unpin for EpochFencedReload
impl UnsafeUnpin for EpochFencedReload
impl UnwindSafe for EpochFencedReload
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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