Skip to main content

sim_lib_openai_server/routes/
response_runtime.rs

1use crate::runtime::{OpenAiFederation, OpenAiRunnerRegistry};
2
3pub use super::execution_record::{
4    GatewayRunExecution as ResponseExecution, GatewayRunIdGenerators as ResponseIdGenerators,
5};
6
7/// Bundles the eval targets a response run may dispatch to: the runner
8/// registry and an optional federation surface for cross-node eval.
9#[derive(Clone, Copy)]
10pub struct ResponseRuntimeTargets<'a> {
11    runners: &'a OpenAiRunnerRegistry,
12    federation: Option<&'a OpenAiFederation>,
13}
14
15impl<'a> ResponseRuntimeTargets<'a> {
16    /// Builds targets backed by the runner registry alone, with no federation.
17    pub fn runners(runners: &'a OpenAiRunnerRegistry) -> Self {
18        Self {
19            runners,
20            federation: None,
21        }
22    }
23
24    /// Builds targets backed by both the runner registry and a federation
25    /// surface.
26    pub fn with_federation(
27        runners: &'a OpenAiRunnerRegistry,
28        federation: &'a OpenAiFederation,
29    ) -> Self {
30        Self {
31            runners,
32            federation: Some(federation),
33        }
34    }
35
36    /// Returns the runner registry.
37    pub fn runners_ref(self) -> &'a OpenAiRunnerRegistry {
38        self.runners
39    }
40
41    /// Returns the federation surface, if one was configured.
42    pub fn federation_ref(self) -> Option<&'a OpenAiFederation> {
43        self.federation
44    }
45}