use std::sync::Arc;
use crate::interface::model::Model;
pub trait TaskRouting: Send + Sync {
fn model_for(&self, task: &str) -> Arc<dyn Model>;
fn model_name_for(&self, task: &str) -> Option<String>;
fn resolve_model(&self, name: &str) -> String;
fn observe(&self, observer: Arc<dyn RouteObserver>);
fn starting_at(&self, provider: &str) -> Result<Arc<dyn TaskRouting>, String>;
fn in_order(&self, provider: &str) -> bool;
fn home_of(&self, model: &str) -> Option<String>;
fn destination(&self, task: &str, model: &str) -> Destination;
}
#[derive(
Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema,
)]
pub struct Destination {
pub provider: String,
pub model: String,
}
#[derive(
Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema,
)]
pub struct ProviderSwitch {
pub from: String,
pub to: String,
pub reason: String,
pub task: String,
}
pub trait RouteObserver: Send + Sync {
fn switched(&self, switch: &ProviderSwitch);
}