pub struct LockPrefix<'a> { /* private fields */ }Expand description
Prefix pattern for lock path creation.
This struct carries path prefix for ephemeral lock path, name filter for candidate contenders and hint to find created lock path in case of Error::ConnectionLoss.
Implementations§
Source§impl<'a> LockPrefix<'a>
 
impl<'a> LockPrefix<'a>
Sourcepub fn new_curator(dir: &'a str, name: &'a str) -> Result<Self, Error>
 
pub fn new_curator(dir: &'a str, name: &'a str) -> Result<Self, Error>
Apache Curator compatible unique prefix pattern, the final lock path will be
{dir}/_c_{uuid}-{name}{ephemeral_sequence}.
§Notable lock names
- latch-for- LeaderLatch.
- lock-for- LeaderSelectorand- InterProcessMutex.
Shared path prefix, the final lock path will be {prefix}{ephemeral_sequence}.
§CAUTION
All contenders share same prefix, so concurrent contenders must not share same session client. Otherwise, the lock could be ruined in case of Error::ConnectionLoss as there is no way to differentiate contenders using same session.
§Notable usages
- Uses “{dir}/n-” as prefixfor ZooKeeper java client’s LeaderElectionSupport.
Sourcepub fn new_custom(prefix: String, name: &'a str) -> Result<Self, Error>
 
pub fn new_custom(prefix: String, name: &'a str) -> Result<Self, Error>
Custom path prefix, the final lock path will be {prefix}{ephemeral_sequence}.
§CAUTION
Don’t reuse same prefix among clients with same session. See LockPrefix::new_shared for details.
§API
It is intentional for prefix parameter to be String but not impl Into<String> nor
impl Into<Cow<'a, str>>, so to attract attention for best wish.
§Notable usages
- Uses “{dir}/x-{session_id}-” as prefixand “x-” or “” asnamefor ZooKeeper java client’s WriteLock.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for LockPrefix<'a>
impl<'a> RefUnwindSafe for LockPrefix<'a>
impl<'a> Send for LockPrefix<'a>
impl<'a> Sync for LockPrefix<'a>
impl<'a> Unpin for LockPrefix<'a>
impl<'a> UnwindSafe for LockPrefix<'a>
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
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