|
| 1 | +//! Proposed Ractor-based membrane supervisor skeleton |
| 2 | +//! |
| 3 | +//! This can live inside lance-graph-callcenter as the orchestration layer |
| 4 | +//! on top of ExternalMembrane. |
| 5 | +
|
| 6 | +use ractor::{Actor, ActorRef, SupervisionEvent}; |
| 7 | + |
| 8 | +/// Top-level supervisor for the lance-graph-callcenter membrane. |
| 9 | +pub struct MembraneSupervisor; |
| 10 | + |
| 11 | +#[derive(Debug)] |
| 12 | +pub enum MembraneMessage { |
| 13 | + Ingest, |
| 14 | + Project, |
| 15 | + Subscribe, |
| 16 | + // ... more intents |
| 17 | +} |
| 18 | + |
| 19 | +impl Actor for MembraneSupervisor { |
| 20 | + type Msg = MembraneMessage; |
| 21 | + type State = (); |
| 22 | + type Arguments = (); |
| 23 | + |
| 24 | + async fn pre_start( |
| 25 | + &self, |
| 26 | + _myself: ActorRef<Self::Msg>, |
| 27 | + _args: Self::Arguments, |
| 28 | + ) -> Result<Self::State, ractor::ActorProcessingErr> { |
| 29 | + // TODO: spawn child actors for different membrane responsibilities |
| 30 | + // e.g. ingestion actor, projection actor, subscription actor, etc. |
| 31 | + Ok(()) |
| 32 | + } |
| 33 | + |
| 34 | + async fn handle( |
| 35 | + &self, |
| 36 | + _myself: ActorRef<Self::Msg>, |
| 37 | + message: Self::Msg, |
| 38 | + _state: &mut Self::State, |
| 39 | + ) -> Result<(), ractor::ActorProcessingErr> { |
| 40 | + match message { |
| 41 | + MembraneMessage::Ingest => { |
| 42 | + // TODO: dispatch to ingestion actor |
| 43 | + } |
| 44 | + MembraneMessage::Project => { |
| 45 | + // TODO: dispatch to projection actor |
| 46 | + } |
| 47 | + MembraneMessage::Subscribe => { |
| 48 | + // TODO: dispatch to subscription / realtime actor |
| 49 | + } |
| 50 | + } |
| 51 | + Ok(()) |
| 52 | + } |
| 53 | + |
| 54 | + async fn handle_supervisor_evt( |
| 55 | + &self, |
| 56 | + _myself: ActorRef<Self::Msg>, |
| 57 | + message: SupervisionEvent, |
| 58 | + _state: &mut Self::State, |
| 59 | + ) -> Result<(), ractor::ActorProcessingErr> { |
| 60 | + match message { |
| 61 | + SupervisionEvent::ActorStarted(_) => {} |
| 62 | + SupervisionEvent::ActorTerminated(actor, _, reason) => { |
| 63 | + tracing::warn!(actor = ?actor, reason = ?reason, "Membrane child actor terminated"); |
| 64 | + } |
| 65 | + _ => {} |
| 66 | + } |
| 67 | + Ok(()) |
| 68 | + } |
| 69 | +} |
0 commit comments