mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-13 06:51:06 +00:00
feat: Added a /health endpoint (#230)
This commit is contained in:
@@ -131,10 +131,17 @@ pub struct NodeCount(pub ChainId, pub usize);
|
||||
/// Message sent to the Aggregator to get the network state of a particular node
|
||||
pub struct GetNetworkState(pub Box<str>, pub NodeId);
|
||||
|
||||
/// Message sent to the Aggregator to get a health check
|
||||
pub struct GetHealth;
|
||||
|
||||
impl Message for GetNetworkState {
|
||||
type Result = Option<Request<Chain, GetNodeNetworkState>>;
|
||||
}
|
||||
|
||||
impl Message for GetHealth {
|
||||
type Result = usize;
|
||||
}
|
||||
|
||||
impl Handler<AddNode> for Aggregator {
|
||||
type Result = ();
|
||||
|
||||
@@ -264,3 +271,11 @@ impl Handler<GetNetworkState> for Aggregator {
|
||||
Some(self.get_chain(&*chain)?.addr.send(GetNodeNetworkState(nid)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler<GetHealth> for Aggregator {
|
||||
type Result = usize;
|
||||
|
||||
fn handle(&mut self, _: GetHealth, _: &mut Self::Context) -> Self::Result {
|
||||
self.chains.len()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user