Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ pub use localfs::FSConfig;
pub use object_storage::{ObjectStorage, ObjectStorageProvider};
pub use s3::S3Config;
pub use store_metadata::{
StorageMetadata, put_remote_metadata, put_staging_metadata, resolve_parseable_metadata,
IngestionQuota, IngestionQuotaType, QuotaPeriod, StorageMetadata, put_remote_metadata,
put_staging_metadata, resolve_parseable_metadata,
};

// metadata file names in a Stream prefix
Expand Down
28 changes: 28 additions & 0 deletions src/storage/store_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ pub struct StaticStorageMetadata {
}

// Type for serialization and deserialization
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IngestionQuota {
#[serde(rename = "type")]
pub quota_type: IngestionQuotaType,
pub limit: u64,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum IngestionQuotaType {
SizeBytes,
EventCount,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum QuotaPeriod {
Monthly,
Yearly,
Lifetime,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct StorageMetadata {
pub version: String,
Expand Down Expand Up @@ -79,6 +101,10 @@ pub struct StorageMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub plan: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ingestion_quota: Option<IngestionQuota>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quota_period: Option<QuotaPeriod>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,
}

Expand All @@ -102,6 +128,8 @@ impl Default for StorageMetadata {
start_date: None,
end_date: None,
plan: None,
ingestion_quota: None,
quota_period: None,
owner: None,
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/tenants/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use itertools::Itertools;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

use crate::{rbac::role::Action, storage::StorageMetadata};
use crate::{
rbac::role::Action,
storage::{IngestionQuota, QuotaPeriod, StorageMetadata},
};

pub static TENANT_METADATA: Lazy<Arc<TenantMetadata>> =
Lazy::new(|| Arc::new(TenantMetadata::default()));
Expand Down Expand Up @@ -70,12 +73,16 @@ impl TenantMetadata {
start_date: Option<String>,
end_date: Option<String>,
plan: Option<String>,
ingestion_quota: Option<IngestionQuota>,
quota_period: Option<QuotaPeriod>,
) -> bool {
if let Some(mut tenant) = self.tenants.get_mut(tenant_id) {
tenant.meta.customer_name = customer_name;
tenant.meta.start_date = start_date;
tenant.meta.end_date = end_date;
tenant.meta.plan = plan;
tenant.meta.ingestion_quota = ingestion_quota;
tenant.meta.quota_period = quota_period;
true
} else {
false
Expand Down
Loading