use crate::domain::entities::{Counter, Gauge, Histogram, Summary};
use crate::domain::events::MetricsEvent;
pub trait CounterPort {
fn inc(&self, delta: u64);
fn get(&self) -> u64;
fn as_entity(&self) -> &Counter;
}
pub trait GaugePort {
fn set(&self, value: f64);
fn add(&self, delta: f64);
fn get(&self) -> f64;
fn as_entity(&self) -> &Gauge;
}
pub trait HistogramPort {
fn record(&self, value: u64);
fn count(&self) -> u64;
fn percentile(&self, p: f64) -> f64;
fn as_entity(&self) -> &Histogram;
}
pub trait SummaryPort {
fn observe(&self, value: f64);
fn count(&self) -> u64;
fn mean(&self) -> f64;
fn as_entity(&self) -> &Summary;
}
pub trait MetricsPort {
fn register_counter(&self, counter: Counter) -> Result<(), String>;
fn register_gauge(&self, gauge: Gauge) -> Result<(), String>;
fn register_histogram(&self, histogram: Histogram) -> Result<(), String>;
fn register_summary(&self, summary: Summary) -> Result<(), String>;
fn get_counter(&self, name: &str) -> Option<Counter>;
fn get_gauge(&self, name: &str) -> Option<Gauge>;
fn get_histogram(&self, name: &str) -> Option<Histogram>;
fn get_summary(&self, name: &str) -> Option<Summary>;
fn list_counters(&self) -> Vec<String>;
fn list_gauges(&self) -> Vec<String>;
fn list_histograms(&self) -> Vec<String>;
fn list_summaries(&self) -> Vec<String>;
}
pub trait EventPort {
fn publish(&mut self, event: MetricsEvent) -> Result<(), String>;
fn get_events_since(&self, timestamp: std::time::SystemTime) -> Vec<MetricsEvent>;
}