pub struct ClientBuilder { /* private fields */ }
Expand description
Client
builder.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn table_name(self, table_name: impl Into<String>) -> Self
pub fn table_name(self, table_name: impl Into<String>) -> Self
Sets the lease table name where the lease info will be stored. The table must have the correct schema.
Default "leases"
.
Sourcepub fn lease_ttl_seconds(self, seconds: u32) -> Self
pub fn lease_ttl_seconds(self, seconds: u32) -> Self
Sets the time to live for each lease (or lease extension) in seconds. Must be at least 2.
Note: Time to live is implemented using the native dynamodb feature. As this is based on unix timestamps the unit is seconds. This makes extending ttls lower than 2s not reliable.
Note: A crate::Lease
will attempt to extend itself in the background until dropped
and then release itself. However, since db comms failing after acquiring a lease
is possible, this ttl is the guaranteed lifetime of a lease. As such, and since
ttl is not in normal operation relied upon to release leases, it may make sense
to set this higher than the max operation time the lease is wrapping.
So, for example, if the locked task can take 1s to 5m a ttl of 10m should provide a decent guarantee that such tasks will never execute concurrently. In normal operation each lease will release (be deleted) immediately after dropping, so having a high ttl only affects the edge case where the extend/drop db interactions fail.
Default 60
.
§Panics
Panics if less than 2s.
Sourcepub fn extend_every(self, extend_period: Duration) -> Self
pub fn extend_every(self, extend_period: Duration) -> Self
Sets the periodic duration between each background attempt to extend the lease. These
happen continually while the crate::Lease
is alive.
Each extension renews the lease to the full ttl. This duration must be less than the ttl.
Default lease_ttl_seconds / 2
.
§Panics
Panics if zero.
Sourcepub fn acquire_cooldown(self, cooldown: Duration) -> Self
pub fn acquire_cooldown(self, cooldown: Duration) -> Self
Sets how long Client::acquire
waits between attempts to acquire a lease.
Default 1s
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnwindSafe for ClientBuilder
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