Skip to main content

meerkat_runtime/handles/
model_routing.rs

1//! Runtime impl of [`meerkat_core::handles::ModelRoutingHandle`].
2
3use std::sync::Arc;
4
5use meerkat_core::handles::{DslTransitionError, ModelRoutingHandle};
6use meerkat_core::lifecycle::run_primitive::ModelId;
7
8use super::HandleDslAuthority;
9use crate::meerkat_machine::dsl as mm_dsl;
10
11/// Runtime-backed [`ModelRoutingHandle`] impl.
12#[derive(Debug)]
13pub struct RuntimeModelRoutingHandle {
14    dsl: Arc<HandleDslAuthority>,
15}
16
17impl RuntimeModelRoutingHandle {
18    /// Construct a handle backed by the session's shared DSL authority.
19    pub fn new(dsl: Arc<HandleDslAuthority>) -> Self {
20        Self { dsl }
21    }
22
23    /// Construct a handle backed by an ephemeral DSL authority.
24    pub fn ephemeral() -> Self {
25        Self::new(Arc::new(HandleDslAuthority::ephemeral()))
26    }
27}
28
29impl ModelRoutingHandle for RuntimeModelRoutingHandle {
30    fn set_baseline(
31        &self,
32        baseline_model: ModelId,
33        realtime_capable: bool,
34    ) -> Result<(), DslTransitionError> {
35        // intra-machine: no route; dispatcher not applicable (handle targets the meerkat DSL directly, not a CompositionDispatcher seam)
36        self.dsl.apply_input(
37            mm_dsl::MeerkatMachineInput::SetModelRoutingBaseline {
38                baseline_model: baseline_model.to_string(),
39                realtime_capable,
40            },
41            "ModelRoutingHandle::set_baseline",
42        )
43    }
44}