Skip to main content

relay_core_runtime/services/
audit.rs

1use async_trait::async_trait;
2use tokio::sync::broadcast;
3use crate::audit::AuditEvent;
4use crate::{CoreAuditQuery, CoreAuditSnapshot, CoreState};
5
6#[async_trait]
7pub trait AuditService: Send + Sync {
8    fn audit_snapshot(&self, limit: usize) -> CoreAuditSnapshot;
9    async fn query_audit_snapshot(&self, query: CoreAuditQuery) -> CoreAuditSnapshot;
10    fn subscribe_audit_events(&self) -> broadcast::Receiver<AuditEvent>;
11    fn record_audit_events_lagged(&self, skipped: u64);
12}
13
14#[async_trait]
15impl AuditService for CoreState {
16    fn audit_snapshot(&self, limit: usize) -> CoreAuditSnapshot {
17        CoreState::audit_snapshot(self, limit)
18    }
19
20    async fn query_audit_snapshot(&self, query: CoreAuditQuery) -> CoreAuditSnapshot {
21        CoreState::query_audit_snapshot(self, query).await
22    }
23
24    fn subscribe_audit_events(&self) -> broadcast::Receiver<AuditEvent> {
25        CoreState::subscribe_audit_events(self)
26    }
27
28    fn record_audit_events_lagged(&self, skipped: u64) {
29        CoreState::record_audit_events_lagged(self, skipped)
30    }
31}