Store incoming reports in the data store
This commit is contained in:
@@ -31,8 +31,8 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
AnyKey, BitmapClass, BlobOp, DirectoryClass, LookupClass, QueueClass, ReportEvent, TagValue,
|
||||
ValueClass,
|
||||
AnyKey, BitmapClass, BlobOp, DirectoryClass, LookupClass, QueueClass, ReportClass, ReportEvent,
|
||||
TagValue, ValueClass,
|
||||
};
|
||||
|
||||
pub struct KeySerializer {
|
||||
@@ -348,6 +348,17 @@ impl<T: AsRef<ValueClass> + Sync + Send> Key for ValueKey<T> {
|
||||
QueueClass::QuotaCount(key) => serializer.write(55u8).write(key.as_slice()),
|
||||
QueueClass::QuotaSize(key) => serializer.write(56u8).write(key.as_slice()),
|
||||
},
|
||||
ValueClass::Report(report) => match report {
|
||||
ReportClass::Tls { id, expires } => {
|
||||
serializer.write(60u8).write(*expires).write(*id)
|
||||
}
|
||||
ReportClass::Dmarc { id, expires } => {
|
||||
serializer.write(61u8).write(*expires).write(*id)
|
||||
}
|
||||
ReportClass::Arf { id, expires } => {
|
||||
serializer.write(62u8).write(*expires).write(*id)
|
||||
}
|
||||
},
|
||||
}
|
||||
.finalize()
|
||||
}
|
||||
@@ -503,6 +514,7 @@ impl ValueClass {
|
||||
}
|
||||
QueueClass::QuotaCount(v) | QueueClass::QuotaSize(v) => v.len(),
|
||||
},
|
||||
ValueClass::Report(_) => U64_LEN * 2 + 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ pub enum ValueClass {
|
||||
IndexEmail(u64),
|
||||
Config(Vec<u8>),
|
||||
Queue(QueueClass),
|
||||
Report(ReportClass),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
|
||||
@@ -172,6 +173,13 @@ pub enum QueueClass {
|
||||
QuotaSize(Vec<u8>),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
|
||||
pub enum ReportClass {
|
||||
Tls { id: u64, expires: u64 },
|
||||
Dmarc { id: u64, expires: u64 },
|
||||
Arf { id: u64, expires: u64 },
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
|
||||
pub struct QueueEvent {
|
||||
pub due: u64,
|
||||
|
||||
@@ -29,7 +29,7 @@ use utils::config::cron::SimpleCron;
|
||||
use crate::{BlobStore, LookupStore, Store};
|
||||
|
||||
pub enum PurgeStore {
|
||||
Bitmaps(Store),
|
||||
Data(Store),
|
||||
Blobs { store: Store, blob_store: BlobStore },
|
||||
Lookup(LookupStore),
|
||||
}
|
||||
@@ -62,11 +62,11 @@ impl PurgeSchedule {
|
||||
}
|
||||
|
||||
let result = match &self.store {
|
||||
PurgeStore::Bitmaps(store) => store.purge_bitmaps().await,
|
||||
PurgeStore::Data(store) => store.purge_store().await,
|
||||
PurgeStore::Blobs { store, blob_store } => {
|
||||
store.purge_blobs(blob_store.clone()).await
|
||||
}
|
||||
PurgeStore::Lookup(store) => store.purge_expired().await,
|
||||
PurgeStore::Lookup(store) => store.purge_lookup_store().await,
|
||||
};
|
||||
|
||||
if let Err(err) = result {
|
||||
@@ -85,7 +85,7 @@ impl PurgeSchedule {
|
||||
impl Display for PurgeStore {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
PurgeStore::Bitmaps(_) => write!(f, "bitmaps"),
|
||||
PurgeStore::Data(_) => write!(f, "bitmaps"),
|
||||
PurgeStore::Blobs { .. } => write!(f, "blobs"),
|
||||
PurgeStore::Lookup(_) => write!(f, "expired keys"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user