use serde::{Deserialize, Serialize};
use std::time::Duration;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IntentSection {
pub entries: Vec<IntentEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IntentEntry {
pub key: Vec<u8>,
pub txn_id: u64,
pub start_ts: u64,
pub intent_type: IntentType,
pub value: Option<Vec<u8>>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum IntentType {
Put = 0,
Delete = 1,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LockSection {
pub entries: Vec<LockEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LockEntry {
pub key: Vec<u8>,
pub txn_id: u64,
pub lock_type: LockType,
pub acquired_ts: u64,
pub ttl_ms: u64,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum LockType {
Shared = 0,
Exclusive = 1,
}
#[derive(Debug, Clone)]
pub struct EphemeralDataGcConfig {
pub intent_flush_interval: Duration,
pub lock_flush_interval: Duration,
pub gc_trigger_entries: usize,
pub gc_trigger_bytes: u64,
pub intent_retention: Duration,
pub lock_retention: Duration,
}
impl Default for EphemeralDataGcConfig {
fn default() -> Self {
Self {
intent_flush_interval: Duration::from_secs(1),
lock_flush_interval: Duration::from_secs(1),
gc_trigger_entries: 1000,
gc_trigger_bytes: 1024 * 1024,
intent_retention: Duration::from_secs(0),
lock_retention: Duration::from_secs(0),
}
}
}