✨ feat(retention): implement data retention policy
- introduce `Retention` struct to define data retention period and label generation flag - add `MessageAge` enum to represent different retention time units (days, months, years) - implement default values for retention policy (5 years, generate label)
This commit is contained in:
committed by
Jeremiah Russell
parent
4390fe4c2d
commit
f63a0f888d
36
src/retention.rs
Normal file
36
src/retention.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
mod message_age;
|
||||||
|
|
||||||
|
pub use message_age::MessageAge;
|
||||||
|
|
||||||
|
/// Define retention period and flag to indicate if label should be generated
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Retention {
|
||||||
|
age: MessageAge,
|
||||||
|
generate_label: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Retention {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
age: MessageAge::Years(5),
|
||||||
|
generate_label: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Retention {
|
||||||
|
pub(crate) fn new(age: MessageAge, generate_label: bool) -> Self {
|
||||||
|
Retention {
|
||||||
|
age,
|
||||||
|
generate_label,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn age(&self) -> &MessageAge {
|
||||||
|
&self.age
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn generate_label(&self) -> bool {
|
||||||
|
self.generate_label
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user