1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::router::Tracker;
use crate::{Config, RouterId};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Debug, Clone)]
pub enum MetricsRequest {
Config,
Router,
Connection(String),
}
#[derive(Debug, Clone)]
pub enum MetricsReply {
Config(Arc<Config>),
Router(RouterMetrics),
Connection(ConnectionMetrics),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RouterMetrics {
pub router_id: RouterId,
pub total_connections: usize,
pub total_topics: usize,
pub total_subscriptions: usize,
}
impl RouterMetrics {
pub fn new(router_id: RouterId) -> RouterMetrics {
RouterMetrics {
router_id,
total_connections: 0,
total_topics: 0,
total_subscriptions: 0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectionMetrics {
id: String,
tracker: Option<Tracker>,
}
impl ConnectionMetrics {
pub fn new(id: String, tracker: Option<Tracker>) -> ConnectionMetrics {
ConnectionMetrics { id, tracker }
}
}