pub struct ResourceLimits {
pub max_db_size_bytes: Option<u64>,
pub max_connections: Option<u64>,
pub max_memory_bytes: Option<u64>,
pub max_qps: Option<u64>,
pub max_query_duration: Option<Duration>,
pub max_result_bytes: Option<u64>,
pub max_batch_size: Option<u64>,
}Expand description
Snapshot of the RED_MAX_* env vars read at runtime
construction. Held by RuntimeInner and accessible via
RedDBRuntime::resource_limits() so observability and
enforcement consult the same values.
Fields§
§max_db_size_bytes: Option<u64>Maximum primary-database file size in bytes. Writes that
would push the file past this value return
RedDBError::QuotaExceeded with a structured payload
({limit:"max_db_size", current, max}). Operator-level
behaviour PLAN.md prescribes: returns HTTP 507 Insufficient
Storage at the public surface.
max_connections: Option<u64>Maximum concurrent client connections. Saturated accept loops return HTTP 503 / wire-protocol error so callers back off cleanly.
max_memory_bytes: Option<u64>Soft memory budget in bytes. Cache eviction fires at this
threshold; the runtime never panics on OOM. 0 disables
the soft cap entirely.
max_qps: Option<u64>Maximum queries-per-second sustained per-instance. Token bucket fires HTTP 429 / wire backoff on excess.
max_query_duration: Option<Duration>Maximum wall time for any single query. Queries past this
threshold are killed and return HTTP 504. None defers to
the OS / cgroup CPU policy.
max_result_bytes: Option<u64>Maximum response payload size in bytes. Larger responses are truncated or errored (decided by the surface).
max_batch_size: Option<u64>Maximum rows per bulk insert / update / delete. Caps the memory the server allocates for any one batch.
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Read limits from env vars. Accepts both the cloud-agnostic
RED_MAX_* family (PLAN.md spec) and the legacy REDDB_MAX_*
form for existing dev installs. Missing or unparseable
values stay None. 0 is treated as “explicitly
unbounded” so operators can disable a deployment-default
cap without unsetting the env.
Sourcepub fn db_size_exceeded(&self, current_bytes: u64) -> bool
pub fn db_size_exceeded(&self, current_bytes: u64) -> bool
Whether max_db_size_bytes is set and current_bytes
exceeds it. Cheap branch — caller decides what to do
(surface-specific error code, refuse new writes, suspend).
pub fn batch_size_exceeded(&self, requested: usize) -> bool
Sourcepub fn check_disk_headroom(
&self,
path: &str,
available_bytes: u64,
threshold_bytes: u64,
) -> bool
pub fn check_disk_headroom( &self, path: &str, available_bytes: u64, threshold_bytes: u64, ) -> bool
Issue #205 — disk-headroom monitor. When available_bytes drops
below threshold_bytes, emit a DiskSpaceCritical operator
event. Returns whether the threshold was breached so callers
can also fail the path that triggered the check. Cheap to call
per-write: the threshold check is one branch and the emit only
runs on breach.
Trait Implementations§
Source§impl Clone for ResourceLimits
impl Clone for ResourceLimits
Source§fn clone(&self) -> ResourceLimits
fn clone(&self) -> ResourceLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceLimits
impl Debug for ResourceLimits
Source§impl Default for ResourceLimits
impl Default for ResourceLimits
Source§fn default() -> ResourceLimits
fn default() -> ResourceLimits
Auto Trait Implementations§
impl Freeze for ResourceLimits
impl RefUnwindSafe for ResourceLimits
impl Send for ResourceLimits
impl Sync for ResourceLimits
impl Unpin for ResourceLimits
impl UnsafeUnpin for ResourceLimits
impl UnwindSafe for ResourceLimits
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request