hypercall_db/traits/
archiver.rs1use anyhow::Result;
8use chrono::{DateTime, Utc};
9
10use crate::{
11 ArchivalBoundary, ArchivedCommand, ArchivedEvent, ArchivedOrderAction, ArchivedOrderUpdate,
12};
13
14pub trait ArchiverReader: Send + Sync {
16 fn find_safe_boundary(&self, min_age_hours: i64) -> Result<ArchivalBoundary>;
19
20 fn fetch_events_batch(
22 &self,
23 max_command_id: i64,
24 age_cutoff: &DateTime<Utc>,
25 batch_size: i64,
26 after_event_id: Option<i64>,
27 ) -> Result<Vec<ArchivedEvent>>;
28
29 fn fetch_orphan_commands_batch(
31 &self,
32 max_command_id: i64,
33 age_cutoff: &DateTime<Utc>,
34 batch_size: i64,
35 after_command_id: Option<i64>,
36 ) -> Result<Vec<ArchivedCommand>>;
37
38 fn fetch_order_actions_batch(
40 &self,
41 age_cutoff: &DateTime<Utc>,
42 batch_size: i64,
43 after_id: Option<i32>,
44 ) -> Result<Vec<ArchivedOrderAction>>;
45
46 fn fetch_order_updates_batch(
48 &self,
49 age_cutoff: &DateTime<Utc>,
50 batch_size: i64,
51 after_id: Option<i32>,
52 ) -> Result<Vec<ArchivedOrderUpdate>>;
53}
54
55pub trait ArchiverWriter: Send + Sync {
57 fn delete_events(&self, event_ids: &[i64]) -> Result<usize>;
59
60 fn delete_commands(&self, command_ids: &[i64]) -> Result<usize>;
62
63 fn delete_order_actions(&self, ids: &[i32]) -> Result<usize>;
65
66 fn delete_order_updates(&self, ids: &[i32]) -> Result<usize>;
68
69 fn delete_notifications_before(&self, cutoff: &DateTime<Utc>, batch_size: i64)
71 -> Result<usize>;
72
73 fn delete_notifications_over_per_user_cap(
75 &self,
76 max_per_user: i64,
77 batch_size: i64,
78 ) -> Result<usize>;
79}