Skip to main content

DatabaseObserver

Trait DatabaseObserver 

Source
pub trait DatabaseObserver: Send + Sync {
    // Provided methods
    fn on_collection_created(&self, _name: &str, _kind: &CollectionType) { ... }
    fn on_collection_deleted(&self, _name: &str) { ... }
    fn on_upsert(&self, _collection: &str, _point_count: usize) { ... }
    fn on_query(&self, _collection: &str, _duration_us: u64) { ... }
}
Expand description

Lifecycle hooks for database events.

Implement this trait in velesdb-premium to attach RBAC, audit logging, multi-tenant routing, or replication logic without modifying the core.

§Example (Premium side)

use velesdb_core::{DatabaseObserver, CollectionType};

struct PremiumObserver { /* audit_log, rbac, tenant_router */ }

impl DatabaseObserver for PremiumObserver {
    fn on_collection_created(&self, name: &str, kind: &CollectionType) {
        // self.audit_log.record(...)
    }
}

Provided Methods§

Source

fn on_collection_created(&self, _name: &str, _kind: &CollectionType)

Called after a collection is successfully created.

Source

fn on_collection_deleted(&self, _name: &str)

Called after a collection is successfully deleted.

Source

fn on_upsert(&self, _collection: &str, _point_count: usize)

Called after points are upserted into a collection.

Source

fn on_query(&self, _collection: &str, _duration_us: u64)

Called after a query is executed, with the duration in microseconds.

Implementors§