pub struct PostgresConfig { /* private fields */ }Expand description
Runtime bounds for PostgreSQL admission work.
With the serde feature, this is an object containing
maximum_rows_per_shard, max_batch_size, pool_acquire_timeout, and
operation_timeout. Durations use Serde’s exact
{ "secs": ..., "nanos": ... } representation. Every field may be omitted
when deserializing to use the constructor defaults.
Implementations§
Source§impl PostgresConfig
impl PostgresConfig
Sourcepub const DEFAULT_MAXIMUM_ROWS_PER_SHARD: u32 = 4_096
pub const DEFAULT_MAXIMUM_ROWS_PER_SHARD: u32 = 4_096
Default configured row limit for each of the 256 capacity shards.
Sourcepub const DEFAULT_MAX_BATCH_SIZE: usize = 32
pub const DEFAULT_MAX_BATCH_SIZE: usize = 32
Default maximum number of checks in one atomic batch.
Sourcepub const DEFAULT_POOL_ACQUIRE_TIMEOUT: Duration
pub const DEFAULT_POOL_ACQUIRE_TIMEOUT: Duration
Default budget for acquiring a connection from the pool.
Sourcepub const DEFAULT_OPERATION_TIMEOUT: Duration
pub const DEFAULT_OPERATION_TIMEOUT: Duration
Default deadline for database work after acquiring a connection.
Sourcepub const MAXIMUM_POOL_ACQUIRE_TIMEOUT: Duration
pub const MAXIMUM_POOL_ACQUIRE_TIMEOUT: Duration
Largest accepted pool-acquisition budget.
Sourcepub const MAXIMUM_OPERATION_TIMEOUT: Duration
pub const MAXIMUM_OPERATION_TIMEOUT: Duration
Largest accepted database-operation deadline.
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Returns the conservative defaults suitable for an online admission path.
Sourcepub fn with_maximum_rows_per_shard(
self,
maximum: u32,
) -> Result<Self, PostgresConfigError>
pub fn with_maximum_rows_per_shard( self, maximum: u32, ) -> Result<Self, PostgresConfigError>
Sets the configured admission limit for one capacity shard.
The database migration independently enforces
HARD_MAX_ROWS_PER_SHARD for compatibility with older replicas.
Configuring a lower value makes this limiter deny new keys sooner.
Existing keys remain usable, including when the ledger is already above
the newly configured value.
§Errors
Returns an error if maximum is zero or exceeds the database-enforced
hard maximum.
Sourcepub fn with_max_batch_size(
self,
maximum: usize,
) -> Result<Self, PostgresConfigError>
pub fn with_max_batch_size( self, maximum: usize, ) -> Result<Self, PostgresConfigError>
Sets the maximum number of checks that may retain locks in one batch.
§Errors
Returns an error if maximum is zero.
Sourcepub fn with_pool_acquire_timeout(
self,
timeout: Duration,
) -> Result<Self, PostgresConfigError>
pub fn with_pool_acquire_timeout( self, timeout: Duration, ) -> Result<Self, PostgresConfigError>
Sets the budget for acquiring a connection from the pool.
A successful acquisition receives a fresh
Self::operation_timeout budget. This timeout is intentionally not
applied to schema migrations.
§Errors
Returns an error if timeout is zero or exceeds 60 seconds.
Sourcepub fn with_operation_timeout(
self,
timeout: Duration,
) -> Result<Self, PostgresConfigError>
pub fn with_operation_timeout( self, timeout: Duration, ) -> Result<Self, PostgresConfigError>
Sets the deadline for database work after acquiring a connection.
The fresh deadline covers transaction begin, lock waits, statements, rollback, and commit. Server-side timeouts are refreshed from the remaining budget before each statement and commit, so an earlier lock wait cannot give a later statement a fresh full-length timeout. It is intentionally not applied to pool acquisition or schema migrations.
§Errors
Returns an error if timeout is zero or exceeds 60 seconds.
Sourcepub const fn max_batch_size(&self) -> usize
pub const fn max_batch_size(&self) -> usize
Returns the maximum accepted batch length.
Sourcepub const fn maximum_rows_per_shard(self) -> u32
pub const fn maximum_rows_per_shard(self) -> u32
Returns the configured admission limit for one capacity shard.
Sourcepub const fn pool_acquire_timeout(self) -> Duration
pub const fn pool_acquire_timeout(self) -> Duration
Returns the budget for acquiring a connection from the pool.
Sourcepub const fn operation_timeout(self) -> Duration
pub const fn operation_timeout(self) -> Duration
Returns the deadline applied after a connection is acquired.
Trait Implementations§
Source§impl Clone for PostgresConfig
impl Clone for PostgresConfig
impl Copy for PostgresConfig
Source§impl Debug for PostgresConfig
impl Debug for PostgresConfig
Source§impl Default for PostgresConfig
impl Default for PostgresConfig
Source§impl<'de> Deserialize<'de> for PostgresConfig
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PostgresConfig
serde only.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 PostgresConfig
Source§impl PartialEq for PostgresConfig
impl PartialEq for PostgresConfig
Source§impl Serialize for PostgresConfig
Available on crate feature serde only.
impl Serialize for PostgresConfig
serde only.impl StructuralPartialEq for PostgresConfig
Auto Trait Implementations§
impl Freeze for PostgresConfig
impl RefUnwindSafe for PostgresConfig
impl Send for PostgresConfig
impl Sync for PostgresConfig
impl Unpin for PostgresConfig
impl UnsafeUnpin for PostgresConfig
impl UnwindSafe for PostgresConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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