use super::types::RuntimeChoice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuntimeTarget {
Backend,
Node,
Browser,
}
impl From<RuntimeChoice> for RuntimeTarget {
fn from(c: RuntimeChoice) -> Self {
match c {
RuntimeChoice::Backend => Self::Backend,
RuntimeChoice::Node => Self::Node,
RuntimeChoice::Browser => Self::Browser,
RuntimeChoice::Hybrid | RuntimeChoice::Auto => Self::Backend,
}
}
}
pub fn route(
plan: &super::types::ExecutionPlan,
profile: &super::resources::ResourceProfile,
) -> RuntimeTarget {
match profile.runtime {
RuntimeChoice::Node => RuntimeTarget::Node,
RuntimeChoice::Browser => RuntimeTarget::Browser,
RuntimeChoice::Hybrid => RuntimeTarget::Backend,
RuntimeChoice::Backend | RuntimeChoice::Auto => {
if plan.chunks > 8 || plan.use_ai {
RuntimeTarget::Backend
} else {
RuntimeTarget::from(plan.runtime)
}
}
}
}