Skip to content

add optional ingestion quota to tenant metadata#1691

Open
nikhilsinhaparseable wants to merge 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:license-change
Open

add optional ingestion quota to tenant metadata#1691
nikhilsinhaparseable wants to merge 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:license-change

Conversation

@nikhilsinhaparseable

@nikhilsinhaparseable nikhilsinhaparseable commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added ingestion quota management for tenants, allowing limits based on data size or event count across monthly, yearly, or lifetime periods.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds three new public types—IngestionQuota, IngestionQuotaType, and QuotaPeriod—to store_metadata.rs with serde serialization. StorageMetadata gains two optional fields for these types. TenantMetadata::update_tenant_meta is extended with matching optional parameters that write into tenant metadata. Re-exports in storage/mod.rs are updated to include the new types.

Changes

Ingestion Quota Modeling

Layer / File(s) Summary
Quota types and StorageMetadata schema
src/storage/store_metadata.rs, src/storage/mod.rs
Introduces IngestionQuota, IngestionQuotaType, and QuotaPeriod with camelCase serde and a renamed type field. Adds ingestion_quota: Option<IngestionQuota> and quota_period: Option<QuotaPeriod> to StorageMetadata, both defaulting to None and skipped during serialization when absent. Re-exports the three new types from the storage module.
Tenant metadata update wiring
src/tenants/mod.rs
Imports the new quota types and adds ingestion_quota and quota_period as optional parameters to update_tenant_meta, assigning them directly to tenant.meta.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A quota was needed, so limits were set,
In bytes or in events—no overflow yet!
Monthly or yearly, lifetime if you dare,
The metadata struct now has fields to spare.
Hopped through the tenants, wired it with care~ ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description provided, missing required sections like Description, solutions/rationale, key changes, and testing/documentation checkboxes. Add a comprehensive description covering the goal, rationale for the changes, key modifications made, and complete the testing and documentation checkboxes from the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding optional ingestion quota fields to tenant metadata structure and update functions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tenants/mod.rs (1)

69-85: ⚠️ Potential issue | 🔴 Critical

Remove unused update_tenant_meta method or implement its callers.

update_tenant_meta is defined as a public method but is never called anywhere in the codebase. Either this method should be removed if it's not needed, or the handlers/endpoints that should invoke it need to be implemented. If this is intentional dead code for a future feature, document the intent with a comment and consider making it private or adding #[allow(dead_code)] to clarify intent.

The partial-update semantics concern about quota fields is valid in principle (both fields are optional in StorageMetadata, and passing None will overwrite persisted values), but this is secondary to the fact that the method is unreachable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tenants/mod.rs` around lines 69 - 85, The `update_tenant_meta` method in
the tenants module is defined as public but is never called anywhere in the
codebase, making it dead code. Determine whether this method is needed: if it is
intentional for a future feature, add a comment explaining the intent and
consider making it private or adding the `#[allow(dead_code)]` attribute; if it
is not needed, remove the entire `update_tenant_meta` method definition;
alternatively, if this method should be invoked by handlers or endpoints,
implement those callers instead.
🧹 Nitpick comments (1)
src/storage/store_metadata.rs (1)

70-75: Add explicit camelCase serde renaming to QuotaPeriod for consistency with IngestionQuotaType.

The IngestionQuotaType enum uses #[serde(rename_all = "camelCase")] and serializes to "sizeBytes" and "eventCount", while QuotaPeriod has no serde attribute and serializes to "Monthly", "Yearly", "Lifetime" (PascalCase). This creates an inconsistent JSON contract. Adding #[serde(rename_all = "camelCase")] to QuotaPeriod would normalize it to "monthly", "yearly", "lifetime".

Proposed change
 #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
+#[serde(rename_all = "camelCase")]
 pub enum QuotaPeriod {
     Monthly,
     Yearly,
     Lifetime,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/storage/store_metadata.rs` around lines 70 - 75, The QuotaPeriod enum
currently serializes to PascalCase (Monthly, Yearly, Lifetime) because it lacks
a serde renaming attribute, while IngestionQuotaType uses #[serde(rename_all =
"camelCase")] to maintain consistency. Add the #[serde(rename_all =
"camelCase")] attribute to the QuotaPeriod enum definition (located above the
pub enum QuotaPeriod line) to normalize serialization to camelCase (monthly,
yearly, lifetime) and match the JSON contract used by IngestionQuotaType.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/tenants/mod.rs`:
- Around line 69-85: The `update_tenant_meta` method in the tenants module is
defined as public but is never called anywhere in the codebase, making it dead
code. Determine whether this method is needed: if it is intentional for a future
feature, add a comment explaining the intent and consider making it private or
adding the `#[allow(dead_code)]` attribute; if it is not needed, remove the
entire `update_tenant_meta` method definition; alternatively, if this method
should be invoked by handlers or endpoints, implement those callers instead.

---

Nitpick comments:
In `@src/storage/store_metadata.rs`:
- Around line 70-75: The QuotaPeriod enum currently serializes to PascalCase
(Monthly, Yearly, Lifetime) because it lacks a serde renaming attribute, while
IngestionQuotaType uses #[serde(rename_all = "camelCase")] to maintain
consistency. Add the #[serde(rename_all = "camelCase")] attribute to the
QuotaPeriod enum definition (located above the pub enum QuotaPeriod line) to
normalize serialization to camelCase (monthly, yearly, lifetime) and match the
JSON contract used by IngestionQuotaType.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fe0548c4-398e-4118-8dc2-11682268ffb8

📥 Commits

Reviewing files that changed from the base of the PR and between b253396 and aefb53c.

📒 Files selected for processing (3)
  • src/storage/mod.rs
  • src/storage/store_metadata.rs
  • src/tenants/mod.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant