pub struct OptimisticController { /* private fields */ }Expand description
Optimistic concurrency controller
Implementations§
Source§impl OptimisticController
impl OptimisticController
Sourcepub fn with_default_strategy(strategy: ResolutionStrategy) -> Self
pub fn with_default_strategy(strategy: ResolutionStrategy) -> Self
Create with a custom default strategy
Sourcepub fn with_max_history(self, max: usize) -> Self
pub fn with_max_history(self, max: usize) -> Self
Set maximum history entries
Sourcepub async fn begin_optimistic(
&self,
agent_id: &str,
resource_id: &str,
) -> OptimisticToken
pub async fn begin_optimistic( &self, agent_id: &str, resource_id: &str, ) -> OptimisticToken
Start an optimistic operation - returns token with current version
Sourcepub async fn commit_optimistic(
&self,
token: OptimisticToken,
new_content_hash: &str,
) -> Result<u64, OptimisticConflict>
pub async fn commit_optimistic( &self, token: OptimisticToken, new_content_hash: &str, ) -> Result<u64, OptimisticConflict>
Commit optimistic operation - returns conflict if version changed
Sourcepub async fn commit_or_resolve(
&self,
token: OptimisticToken,
new_content_hash: &str,
new_content: Option<&str>,
) -> Result<CommitResult, String>
pub async fn commit_or_resolve( &self, token: OptimisticToken, new_content_hash: &str, new_content: Option<&str>, ) -> Result<CommitResult, String>
Try to commit, and if conflict occurs, resolve it
Sourcepub async fn resolve_conflict(
&self,
conflict: &OptimisticConflictDetails,
) -> Resolution
pub async fn resolve_conflict( &self, conflict: &OptimisticConflictDetails, ) -> Resolution
Manually resolve a conflict with full details
Sourcepub async fn register_strategy(
&self,
resource_pattern: &str,
strategy: ResolutionStrategy,
)
pub async fn register_strategy( &self, resource_pattern: &str, strategy: ResolutionStrategy, )
Register a resolution strategy for a resource pattern
Sourcepub async fn get_version(&self, resource_id: &str) -> Option<ResourceVersion>
pub async fn get_version(&self, resource_id: &str) -> Option<ResourceVersion>
Get the current version of a resource
Sourcepub async fn has_changed(&self, resource_id: &str, since_version: u64) -> bool
pub async fn has_changed(&self, resource_id: &str, since_version: u64) -> bool
Check if a resource has been modified since a given version
Sourcepub async fn get_conflict_history(&self) -> Vec<ConflictRecord>
pub async fn get_conflict_history(&self) -> Vec<ConflictRecord>
Get conflict history
Sourcepub async fn clear_history(&self)
pub async fn clear_history(&self)
Clear conflict history
Sourcepub async fn get_stats(&self) -> OptimisticStats
pub async fn get_stats(&self) -> OptimisticStats
Get statistics about conflicts
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OptimisticController
impl !RefUnwindSafe for OptimisticController
impl Send for OptimisticController
impl Sync for OptimisticController
impl Unpin for OptimisticController
impl UnsafeUnpin for OptimisticController
impl !UnwindSafe for OptimisticController
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