pub struct RedLockHelper;Expand description
Helper functions for RedLock algorithm.
Implementations§
Source§impl RedLockHelper
impl RedLockHelper
Sourcepub fn has_sufficient_successes(
success_count: usize,
database_count: usize,
) -> bool
pub fn has_sufficient_successes( success_count: usize, database_count: usize, ) -> bool
Checks if we have sufficient successes for majority consensus.
For N servers, we need at least (N/2 + 1) successes.
Sourcepub fn has_too_many_failures_or_faults(
failure_or_fault_count: usize,
database_count: usize,
) -> bool
pub fn has_too_many_failures_or_faults( failure_or_fault_count: usize, database_count: usize, ) -> bool
Checks if we have too many failures/faults to achieve majority.
For odd N: need (N/2 + 1) failures to rule out majority. For even N: need (N/2 + 1) failures to rule out majority.
Sourcepub fn create_lock_id() -> String
pub fn create_lock_id() -> String
Generates a unique lock ID.
Format: {process_id}_{counter}_{random_uuid}
Sourcepub fn now_millis() -> u64
pub fn now_millis() -> u64
Gets current time in milliseconds since Unix epoch.
Auto Trait Implementations§
impl Freeze for RedLockHelper
impl RefUnwindSafe for RedLockHelper
impl Send for RedLockHelper
impl Sync for RedLockHelper
impl Unpin for RedLockHelper
impl UnwindSafe for RedLockHelper
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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