feat: Added a /health endpoint (#230)

This commit is contained in:
Maciej Hirsz
2020-02-18 13:59:12 +01:00
committed by GitHub
parent 483cf81c2d
commit ff29540d56
2 changed files with 33 additions and 3 deletions
+15
View File
@@ -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()
}
}