Skip to main content

AuditSink

Trait AuditSink 

Source
pub trait AuditSink: Send + Sync {
    // Required methods
    fn record(&self, event: AuditEvent) -> Result<(), AuditError>;
    fn flush(&self) -> Result<(), AuditError>;

    // Provided method
    fn is_healthy(&self) -> bool { ... }
}
Expand description

Trait for audit event sinks

Framework users implement this trait to customize where audit events are sent.

§Example

use sen_plugin_host::audit::{AuditSink, AuditEvent, AuditError};

struct MyCloudAuditSink {
    endpoint: String,
}

impl AuditSink for MyCloudAuditSink {
    fn record(&self, event: AuditEvent) -> Result<(), AuditError> {
        // Send to cloud service
        println!("Would send to {}: {:?}", self.endpoint, event);
        Ok(())
    }

    fn flush(&self) -> Result<(), AuditError> {
        Ok(())
    }
}

Required Methods§

Source

fn record(&self, event: AuditEvent) -> Result<(), AuditError>

Record an audit event

Source

fn flush(&self) -> Result<(), AuditError>

Flush any buffered events

Provided Methods§

Source

fn is_healthy(&self) -> bool

Check if the sink is healthy/available

Implementors§