pub struct BackupConfig {
pub s3_url: String,
pub wal_interval_ms: u64,
pub manifest_interval_s: u64,
pub retain_n: usize,
pub sse: Option<String>,
pub lease_ttl_s: u64,
pub lease_conditional: bool,
pub op_timeout_ms: u64,
pub shutdown_grace_ms: u64,
}Expand description
Backup settings, read from the environment by BackupConfig::from_env.
Fields§
§s3_url: StringMUSHROOMDB_BACKUP_S3_URL: s3://bucket/prefix, r2://bucket/prefix
or minio://bucket/prefix.
wal_interval_ms: u64MUSHROOMDB_BACKUP_WAL_INTERVAL_MS: how often new WAL bytes ship.
manifest_interval_s: u64MUSHROOMDB_BACKUP_MANIFEST_INTERVAL_S: how often a manifest is
written while segments accumulate between snapshots.
retain_n: usizeMUSHROOMDB_BACKUP_RETAIN_N: manifests kept; 0 keeps every one.
sse: Option<String>MUSHROOMDB_BACKUP_SSE: server-side encryption (AES256, aws:kms,
aws:kms:dsse), or None for the bucket’s default.
lease_ttl_s: u64MUSHROOMDB_BACKUP_LEASE_TTL: bucket-lease TTL in seconds (at least
1). The holder renews every third of it and stops writing two thirds
in; another instance may take the lease over once it is this old.
lease_conditional: boolMUSHROOMDB_BACKUP_LEASE_CONDITIONAL: on (the default) takes and
renews the lease with conditional PUTs (If-None-Match / If-Match),
which AWS S3, R2 and MinIO honor; off for a service that rejects
those headers, leaving the lease best-effort (see crate::lease).
op_timeout_ms: u64MUSHROOMDB_BACKUP_OP_TIMEOUT_MS: the most one object-store request
(one PUT, one part, one GET, one LIST, one DELETE) may take before the
worker gives up on it and counts a failure. The client’s own retries
can otherwise hold a black-holed bucket for minutes.
shutdown_grace_ms: u64MUSHROOMDB_BACKUP_SHUTDOWN_GRACE_MS: how long the shutdown flush may
take before the in-flight upload is abandoned and the worker stops.
Implementations§
Source§impl BackupConfig
impl BackupConfig
Sourcepub fn from_env() -> Result<Option<Self>, BackupError>
pub fn from_env() -> Result<Option<Self>, BackupError>
Read the configuration from the process environment. Ok(None) when
MUSHROOMDB_BACKUP_S3_URL is unset or empty: backup is off.
§Errors
A set but malformed value — a backup the operator asked for is never silently turned off by a typo.
Sourcepub fn from_lookup(
get: impl Fn(&str) -> Option<String>,
) -> Result<Option<Self>, BackupError>
pub fn from_lookup( get: impl Fn(&str) -> Option<String>, ) -> Result<Option<Self>, BackupError>
from_env over any variable lookup.
Sourcepub fn new(s3_url: impl Into<String>) -> Self
pub fn new(s3_url: impl Into<String>) -> Self
A configuration for s3_url with every other setting at its default.
Sourcepub fn shutdown_budget(&self) -> Duration
pub fn shutdown_budget(&self) -> Duration
The longest a shutdown can keep the process alive on account of the
backup: the flush’s grace, then the lease release (one request, one
op_timeout_ms), plus SHUTDOWN_MARGIN for scheduling. The serve
loop waits this long for the worker, so a platform’s stop timeout
must exceed it by whatever the HTTP drain and the shutdown snapshot
take (see the deployment guide).
Sourcepub fn fit_shutdown_within(&mut self, within: Duration)
pub fn fit_shutdown_within(&mut self, within: Duration)
Shrink the flush grace and the request deadline until they, plus a
margin of at most SHUTDOWN_MARGIN, fit in within, keeping their
ratio. Does nothing when shutdown_budget
already fits. For a serve whose whole shutdown window is shorter than
the configured bounds: the lease release still gets a request deadline
of its own.
Sourcepub fn location(&self) -> Result<S3Location, BackupError>
pub fn location(&self) -> Result<S3Location, BackupError>
The bucket and prefix s3_url names.
Trait Implementations§
Source§impl Clone for BackupConfig
impl Clone for BackupConfig
Source§impl Debug for BackupConfig
impl Debug for BackupConfig
impl Eq for BackupConfig
Source§impl PartialEq for BackupConfig
impl PartialEq for BackupConfig
impl StructuralPartialEq for BackupConfig
Auto Trait Implementations§
impl Forget for BackupConfig
impl Freeze for BackupConfig
impl RefUnwindSafe for BackupConfig
impl Send for BackupConfig
impl Sync for BackupConfig
impl Unpin for BackupConfig
impl UnsafeUnpin for BackupConfig
impl UnwindSafe for BackupConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.