pub struct PartitionGuard {
pub partition_id: u32,
pub epoch: u64,
pub node_id: NodeId,
/* private fields */
}Expand description
An epoch-fenced guard for a single partition.
The hot-path check() is a single atomic load, designed for
sub-10ns latency in the event processing loop.
Fields§
§partition_id: u32The partition this guard protects.
epoch: u64The epoch at which this node acquired ownership.
node_id: NodeIdThe owning node.
Implementations§
Source§impl PartitionGuard
impl PartitionGuard
Sourcepub fn new(partition_id: u32, epoch: u64, node_id: NodeId) -> Self
pub fn new(partition_id: u32, epoch: u64, node_id: NodeId) -> Self
Create a new guard for a partition at the given epoch.
Sourcepub fn check(&self) -> Result<(), EpochError>
pub fn check(&self) -> Result<(), EpochError>
Fast-path epoch check (single atomic load).
Returns Ok(()) if this node still owns the partition at the
expected epoch. Returns Err(EpochError::Fenced) if the epoch
has advanced (meaning ownership has changed).
§Errors
Returns EpochError::Fenced if the partition’s epoch has changed.
Sourcepub fn update_cached_epoch(&self, new_epoch: u64)
pub fn update_cached_epoch(&self, new_epoch: u64)
Update the cached epoch from an external source (e.g., Raft read).
Called periodically by the health-check task to propagate epoch changes from the Raft state machine.
Sourcepub fn cached_epoch_handle(&self) -> Arc<AtomicU64> ⓘ
pub fn cached_epoch_handle(&self) -> Arc<AtomicU64> ⓘ
Get a handle to the cached epoch atomic for external updates.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PartitionGuard
impl RefUnwindSafe for PartitionGuard
impl Send for PartitionGuard
impl Sync for PartitionGuard
impl Unpin for PartitionGuard
impl UnsafeUnpin for PartitionGuard
impl UnwindSafe for PartitionGuard
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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