hyperactor_mesh/
supervision.rs1use hyperactor::Bind;
12use hyperactor::Unbind;
13use hyperactor::actor::ActorErrorKind;
14use hyperactor::actor::ActorStatus;
15use hyperactor::context;
16use hyperactor::supervision::ActorSupervisionEvent;
17use serde::Deserialize;
18use serde::Serialize;
19use typeuri::Named;
20
21#[derive(Clone, Debug, Serialize, Deserialize, Named, PartialEq, Bind, Unbind)]
24pub struct MeshFailure {
25 pub actor_mesh_name: Option<String>,
27 pub rank: Option<usize>,
30 pub event: ActorSupervisionEvent,
32}
33wirevalue::register_type!(MeshFailure);
34
35impl MeshFailure {
36 pub fn default_handler(&self, cx: &impl context::Actor) -> Result<(), anyhow::Error> {
39 let err = ActorErrorKind::UnhandledSupervisionEvent(Box::new(ActorSupervisionEvent::new(
42 cx.instance().self_id().clone(),
43 None,
44 ActorStatus::Failed(ActorErrorKind::UnhandledSupervisionEvent(Box::new(
45 self.event.clone(),
46 ))),
47 None,
48 )));
49 Err(anyhow::Error::new(err))
50 }
51}
52
53impl std::fmt::Display for MeshFailure {
54 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55 write!(
56 f,
57 "Supervision failure on mesh {:?} at rank {:?} with event: {}",
58 self.actor_mesh_name, self.rank, self.event
59 )
60 }
61}
62
63#[derive(Debug, Clone)]
65pub(crate) enum Unhealthy {
66 StreamClosed(MeshFailure), Crashed(MeshFailure), }