pub struct AuditLog { /* private fields */ }Expand description
An append-only, bounded audit log for coordinator state changes.
Thread-safety note: this struct is not internally synchronised. In a
multi-threaded context, wrap it in Arc<Mutex<AuditLog>> or similar.
Implementations§
Source§impl AuditLog
impl AuditLog
Sourcepub fn new(config: AuditLogConfig) -> Self
pub fn new(config: AuditLogConfig) -> Self
Create a new audit log with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new audit log with default configuration.
Sourcepub fn append(&mut self, builder: AuditEntryBuilder) -> Option<u64>
pub fn append(&mut self, builder: AuditEntryBuilder) -> Option<u64>
Append an entry built from a builder.
Returns the assigned sequence number, or None if the event was
filtered out by the minimum severity setting.
Sourcepub fn log_job_submitted(
&mut self,
job_id: Uuid,
actor: &str,
codec: &str,
) -> Option<u64>
pub fn log_job_submitted( &mut self, job_id: Uuid, actor: &str, codec: &str, ) -> Option<u64>
Convenience: log a job submission.
Sourcepub fn log_job_cancelled(
&mut self,
job_id: Uuid,
actor: &str,
reason: &str,
) -> Option<u64>
pub fn log_job_cancelled( &mut self, job_id: Uuid, actor: &str, reason: &str, ) -> Option<u64>
Convenience: log a job cancellation.
Sourcepub fn log_job_failed(
&mut self,
job_id: Uuid,
actor: &str,
error: &str,
) -> Option<u64>
pub fn log_job_failed( &mut self, job_id: Uuid, actor: &str, error: &str, ) -> Option<u64>
Convenience: log a job failure.
Sourcepub fn log_worker_joined(&mut self, worker_id: &str, addr: &str) -> Option<u64>
pub fn log_worker_joined(&mut self, worker_id: &str, addr: &str) -> Option<u64>
Convenience: log a worker joining the cluster.
Sourcepub fn log_worker_left(&mut self, worker_id: &str, reason: &str) -> Option<u64>
pub fn log_worker_left(&mut self, worker_id: &str, reason: &str) -> Option<u64>
Convenience: log a worker leaving the cluster.
Sourcepub fn log_leader_elected(&mut self, leader_id: &str, term: u64) -> Option<u64>
pub fn log_leader_elected(&mut self, leader_id: &str, term: u64) -> Option<u64>
Convenience: log a leader election.
Sourcepub fn total_appended(&self) -> u64
pub fn total_appended(&self) -> u64
Total entries ever appended (including evicted).
Sourcepub fn get_by_sequence(&self, seq: u64) -> Option<&AuditEntry>
pub fn get_by_sequence(&self, seq: u64) -> Option<&AuditEntry>
Get an entry by sequence number.
Sourcepub fn recent(&self, n: usize) -> Vec<&AuditEntry>
pub fn recent(&self, n: usize) -> Vec<&AuditEntry>
Return the most recent n entries (newest last).
Sourcepub fn query_by_kind(&self, kind: AuditEventKind) -> Vec<&AuditEntry>
pub fn query_by_kind(&self, kind: AuditEventKind) -> Vec<&AuditEntry>
Query entries by event kind.
Sourcepub fn query_by_actor(&self, actor: &str) -> Vec<&AuditEntry>
pub fn query_by_actor(&self, actor: &str) -> Vec<&AuditEntry>
Query entries by actor.
Sourcepub fn query_by_target(&self, target: &str) -> Vec<&AuditEntry>
pub fn query_by_target(&self, target: &str) -> Vec<&AuditEntry>
Query entries by target.
Sourcepub fn query_by_min_severity(&self, min: AuditSeverity) -> Vec<&AuditEntry>
pub fn query_by_min_severity(&self, min: AuditSeverity) -> Vec<&AuditEntry>
Query entries by severity at or above the given level.
Sourcepub fn query_by_time_range(
&self,
start_us: u64,
end_us: u64,
) -> Vec<&AuditEntry>
pub fn query_by_time_range( &self, start_us: u64, end_us: u64, ) -> Vec<&AuditEntry>
Query entries within a time range (microseconds since Unix epoch).
Sourcepub fn export_all(&self) -> Vec<AuditEntry>
pub fn export_all(&self) -> Vec<AuditEntry>
Export all entries as a vector (for serialization or transfer).
Auto Trait Implementations§
impl !Freeze for AuditLog
impl RefUnwindSafe for AuditLog
impl Send for AuditLog
impl Sync for AuditLog
impl Unpin for AuditLog
impl UnsafeUnpin for AuditLog
impl UnwindSafe for AuditLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request