use std::time::Duration;
use common::ObjectStoreConfig;
use serde::{Deserialize, Serialize};
use serde_with::{DurationMilliSeconds, serde_as};
use crate::model::CompressionType;
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProducerConfig {
pub object_store: ObjectStoreConfig,
#[serde(default = "default_data_path_prefix")]
pub data_path_prefix: String,
#[serde(default = "default_manifest_path")]
pub manifest_path: String,
#[serde_as(as = "DurationMilliSeconds<u64>")]
#[serde(default = "default_flush_interval")]
pub flush_interval: Duration,
#[serde(default = "default_flush_size_bytes")]
pub flush_size_bytes: usize,
#[serde(default = "default_max_buffered_inputs")]
pub max_buffered_inputs: usize,
#[serde(default)]
pub batch_compression: CompressionType,
}
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConsumerConfig {
pub object_store: ObjectStoreConfig,
#[serde(default = "default_manifest_path")]
pub manifest_path: String,
#[serde(default = "default_data_path_prefix")]
pub data_path_prefix: String,
#[serde_as(as = "DurationMilliSeconds<u64>")]
#[serde(default = "default_gc_interval")]
pub gc_interval: Duration,
#[serde_as(as = "DurationMilliSeconds<u64>")]
#[serde(default = "default_gc_grace_period")]
pub gc_grace_period: Duration,
}
fn default_data_path_prefix() -> String {
"ingest".to_string()
}
fn default_manifest_path() -> String {
"ingest/manifest".to_string()
}
fn default_flush_interval() -> Duration {
Duration::from_millis(100)
}
fn default_flush_size_bytes() -> usize {
64 * 1024 * 1024
}
fn default_max_buffered_inputs() -> usize {
1000
}
fn default_gc_interval() -> Duration {
Duration::from_mins(5)
}
fn default_gc_grace_period() -> Duration {
Duration::from_mins(10)
}