loadwise-core 0.1.0

Core traits, strategies, and in-memory stores for loadwise
Documentation
//! Optional observability hooks — bring your own Prometheus / OpenTelemetry.

use std::fmt;

use crate::health::HealthStatus;

/// Callback interface for observability. The library never pulls in metrics/tracing
/// dependencies — users implement this to bridge to their own stack.
pub trait MetricsCollector: Send + Sync {
    /// Called each time a strategy selects a node.
    fn on_selection(&self, node_id: &dyn fmt::Debug, strategy_name: &str);
    /// Called when a node's health status transitions.
    fn on_health_change(&self, node_id: &dyn fmt::Debug, from: HealthStatus, to: HealthStatus);
}

/// Default no-op implementation.
pub struct NoopCollector;

impl MetricsCollector for NoopCollector {
    fn on_selection(&self, _node_id: &dyn fmt::Debug, _strategy_name: &str) {}
    fn on_health_change(&self, _node_id: &dyn fmt::Debug, _from: HealthStatus, _to: HealthStatus) {
    }
}