feat(group-quota): per-group shared-collection quotas (M3)
Global env-var ceilings enforced in the group write path (mirrors the per-value caps): PICLOUD_GROUP_KV_MAX_ROWS / _DOCS_MAX_ROWS (per-group row count, checked only on a NEW key/doc — updates exempt) and _FILES_MAX_TOTAL_BYTES (per-group total blob bytes). New group_quota env helpers; count_rows/total_bytes repo methods (trait-default 0 for non-Postgres); QuotaExceeded error variants on the three group error enums; a with_max_rows test builder. Pinned by a group_kv_service unit test (3rd key rejected, update of an existing key at the cap allowed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,11 @@ pub enum GroupDocsError {
|
||||
#[error("group docs: data too large ({actual} bytes; limit {limit})")]
|
||||
ValueTooLarge { limit: usize, actual: usize },
|
||||
|
||||
/// The owning group's shared-docs store is at its row quota
|
||||
/// (`PICLOUD_GROUP_DOCS_MAX_ROWS`); a new doc is rejected.
|
||||
#[error("group docs: quota exceeded ({actual} rows; limit {limit})")]
|
||||
QuotaExceeded { limit: usize, actual: usize },
|
||||
|
||||
#[error("group docs backend error: {0}")]
|
||||
Backend(String),
|
||||
}
|
||||
|
||||
@@ -160,6 +160,11 @@ pub enum GroupFilesError {
|
||||
#[error("file too large: {size} bytes exceeds limit of {limit} bytes")]
|
||||
TooLarge { size: usize, limit: usize },
|
||||
|
||||
/// The owning group's shared-files store is at its total-bytes quota
|
||||
/// (`PICLOUD_GROUP_FILES_MAX_TOTAL_BYTES`); the write is rejected.
|
||||
#[error("group files: quota exceeded ({actual} bytes; limit {limit})")]
|
||||
QuotaExceeded { limit: u64, actual: u64 },
|
||||
|
||||
#[error("file name too long: {0} bytes exceeds 255")]
|
||||
NameTooLong(usize),
|
||||
|
||||
|
||||
@@ -135,6 +135,12 @@ pub enum GroupKvError {
|
||||
#[error("group kv: value too large ({actual} bytes; limit {limit})")]
|
||||
ValueTooLarge { limit: usize, actual: usize },
|
||||
|
||||
/// The owning group's shared-KV store is at its row quota
|
||||
/// (`PICLOUD_GROUP_KV_MAX_ROWS`); a new key is rejected (an update of an
|
||||
/// existing key is exempt).
|
||||
#[error("group kv: quota exceeded ({actual} rows; limit {limit})")]
|
||||
QuotaExceeded { limit: usize, actual: usize },
|
||||
|
||||
/// Anything else — Postgres unavailable, serialization failure, etc.
|
||||
#[error("group kv backend error: {0}")]
|
||||
Backend(String),
|
||||
|
||||
Reference in New Issue
Block a user