Struct dynamodb_lease::ClientBuilder
source · 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.