pub trait DLockBackend:
Send
+ Sync
+ 'static {
// Required methods
fn try_acquire<'a>(
&'a self,
key: &'a str,
token: &'a str,
ttl_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, String>> + Send + 'a>>;
fn release<'a>(
&'a self,
key: &'a str,
token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'a>>;
fn renew<'a>(
&'a self,
key: &'a str,
token: &'a str,
ttl_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'a>>;
}Expand description
Storage backend (Redis in production). Implementations MUST make
try_acquire atomic (single Lua script / transaction).
Required Methods§
Sourcefn try_acquire<'a>(
&'a self,
key: &'a str,
token: &'a str,
ttl_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, String>> + Send + 'a>>
fn try_acquire<'a>( &'a self, key: &'a str, token: &'a str, ttl_ms: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, String>> + Send + 'a>>
Atomically: if key is free, store token with ttl_ms and return
Some(fencing_token) from a monotonic cluster counter; else None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".