pub struct SingleKeyConditionalStore { /* private fields */ }Expand description
Deterministic single-key conditional store backed by versioned records.
Implementations§
Source§impl SingleKeyConditionalStore
impl SingleKeyConditionalStore
Sourcepub fn new(epoch: ClusterEpoch, partition_count: u32) -> Self
pub fn new(epoch: ClusterEpoch, partition_count: u32) -> Self
Create an empty conditional store.
Sourcepub fn with_lock_acquire_limit(self, limit: Option<u32>) -> Self
pub fn with_lock_acquire_limit(self, limit: Option<u32>) -> Self
Configure the reentrant acquire limit. None keeps Hazelcast-style unbounded reentrancy.
Sourcepub fn metrics(&self) -> ConditionalMetrics
pub fn metrics(&self) -> ConditionalMetrics
Return current metrics.
Sourcepub fn record(&self, key: &str) -> Option<&ReplicatedValueRecord>
pub fn record(&self, key: &str) -> Option<&ReplicatedValueRecord>
Return the record for a key.
Sourcepub fn current_value(&self, key: &str) -> Option<Vec<u8>>
pub fn current_value(&self, key: &str) -> Option<Vec<u8>>
Return the current live value for a key, treating tombstones as absent.
Sourcepub fn lock_hold(&self, key: &str) -> Option<&LockHold>
pub fn lock_hold(&self, key: &str) -> Option<&LockHold>
Return the current lock hold for a key.
Sourcepub fn is_locked_by(&self, key: &str, owner: &LockOwner) -> bool
pub fn is_locked_by(&self, key: &str, owner: &LockOwner) -> bool
Return whether a lock is currently held by owner.
Sourcepub fn current_fence(&self, key: &str) -> Option<FenceToken>
pub fn current_fence(&self, key: &str) -> Option<FenceToken>
Return the current fence token for a held lock.
Sourcepub fn apply_tombstone(&mut self, key: &str, version: ValueVersion)
pub fn apply_tombstone(&mut self, key: &str, version: ValueVersion)
Apply a tombstone at an explicit version, preserving A5 delete semantics.
Sourcepub fn compare_and_set(
&mut self,
key: &str,
expected: Option<&[u8]>,
new_value: Vec<u8>,
level: ConsistencyLevel,
) -> Result<CasResult, ConditionalError>
pub fn compare_and_set( &mut self, key: &str, expected: Option<&[u8]>, new_value: Vec<u8>, level: ConsistencyLevel, ) -> Result<CasResult, ConditionalError>
Compare and set one key at a linearizable-capable level.
Sourcepub fn put_if_absent(
&mut self,
key: &str,
value: Vec<u8>,
level: ConsistencyLevel,
) -> Result<CasResult, ConditionalError>
pub fn put_if_absent( &mut self, key: &str, value: Vec<u8>, level: ConsistencyLevel, ) -> Result<CasResult, ConditionalError>
Put one key only if it is absent or tombstoned.
Sourcepub fn replace_if_present(
&mut self,
key: &str,
new_value: Vec<u8>,
level: ConsistencyLevel,
) -> Result<CasResult, ConditionalError>
pub fn replace_if_present( &mut self, key: &str, new_value: Vec<u8>, level: ConsistencyLevel, ) -> Result<CasResult, ConditionalError>
Replace one key only when a live value is currently present.
Sourcepub fn remove_if_value(
&mut self,
key: &str,
expected: &[u8],
level: ConsistencyLevel,
) -> Result<CasResult, ConditionalError>
pub fn remove_if_value( &mut self, key: &str, expected: &[u8], level: ConsistencyLevel, ) -> Result<CasResult, ConditionalError>
Remove one key by writing a tombstone only when the live value matches.
Sourcepub fn reject_multi_key<'a, I>(keys: I) -> Result<(), ConditionalError>where
I: IntoIterator<Item = &'a str>,
pub fn reject_multi_key<'a, I>(keys: I) -> Result<(), ConditionalError>where
I: IntoIterator<Item = &'a str>,
Reject multi-key conditional attempts loudly.
Sourcepub fn try_acquire_lock(
&mut self,
key: &str,
level: ConsistencyLevel,
owner: LockOwner,
lease: LogicalDuration,
now: LogicalTime,
) -> Result<Option<FenceToken>, ConditionalError>
pub fn try_acquire_lock( &mut self, key: &str, level: ConsistencyLevel, owner: LockOwner, lease: LogicalDuration, now: LogicalTime, ) -> Result<Option<FenceToken>, ConditionalError>
Try to acquire a fenced lock.
Sourcepub fn force_acquire_lock(
&mut self,
key: &str,
level: ConsistencyLevel,
owner: LockOwner,
lease: LogicalDuration,
now: LogicalTime,
) -> Result<FenceToken, ConditionalError>
pub fn force_acquire_lock( &mut self, key: &str, level: ConsistencyLevel, owner: LockOwner, lease: LogicalDuration, now: LogicalTime, ) -> Result<FenceToken, ConditionalError>
Force lock ownership to advance, simulating lease expiry / failover in deterministic tests.
Sourcepub fn renew_lease(
&mut self,
key: &str,
owner: &LockOwner,
token: FenceToken,
new_deadline: LogicalTime,
) -> Result<(), ConditionalError>
pub fn renew_lease( &mut self, key: &str, owner: &LockOwner, token: FenceToken, new_deadline: LogicalTime, ) -> Result<(), ConditionalError>
Renew a lock lease for the current owner.
Sourcepub fn record_session_heartbeat(&mut self, session: SessionId, now: LogicalTime)
pub fn record_session_heartbeat(&mut self, session: SessionId, now: LogicalTime)
Record a logical session heartbeat.
Sourcepub fn expire_due(&mut self, now: LogicalTime) -> usize
pub fn expire_due(&mut self, now: LogicalTime) -> usize
Expire all lock holds with lease deadlines at or before now.
Sourcepub fn expire_lost_sessions(
&mut self,
now: LogicalTime,
max_silence: LogicalDuration,
) -> usize
pub fn expire_lost_sessions( &mut self, now: LogicalTime, max_silence: LogicalDuration, ) -> usize
Expire all lock holds owned by sessions that stopped heartbeating.
Sourcepub fn release_lock(
&mut self,
key: &str,
owner: &LockOwner,
token: FenceToken,
) -> Result<(), ConditionalError>
pub fn release_lock( &mut self, key: &str, owner: &LockOwner, token: FenceToken, ) -> Result<(), ConditionalError>
Release a fenced lock when the token is current.
Sourcepub fn force_unlock(&mut self, key: &str) -> Option<FenceToken>
pub fn force_unlock(&mut self, key: &str) -> Option<FenceToken>
Privileged release that advances the fencing sequence without requiring ownership.
Sourcepub fn validate_fence_token(
&mut self,
key: &str,
token: FenceToken,
) -> Result<(), ConditionalError>
pub fn validate_fence_token( &mut self, key: &str, token: FenceToken, ) -> Result<(), ConditionalError>
Validate that a token is still current.
Trait Implementations§
Source§impl Clone for SingleKeyConditionalStore
impl Clone for SingleKeyConditionalStore
Source§fn clone(&self) -> SingleKeyConditionalStore
fn clone(&self) -> SingleKeyConditionalStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SingleKeyConditionalStore
impl Debug for SingleKeyConditionalStore
Source§impl<'de> Deserialize<'de> for SingleKeyConditionalStore
impl<'de> Deserialize<'de> for SingleKeyConditionalStore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SingleKeyConditionalStore
Source§impl PartialEq for SingleKeyConditionalStore
impl PartialEq for SingleKeyConditionalStore
Source§fn eq(&self, other: &SingleKeyConditionalStore) -> bool
fn eq(&self, other: &SingleKeyConditionalStore) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SingleKeyConditionalStore
Auto Trait Implementations§
impl Freeze for SingleKeyConditionalStore
impl RefUnwindSafe for SingleKeyConditionalStore
impl Send for SingleKeyConditionalStore
impl Sync for SingleKeyConditionalStore
impl Unpin for SingleKeyConditionalStore
impl UnsafeUnpin for SingleKeyConditionalStore
impl UnwindSafe for SingleKeyConditionalStore
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.