[model-gateway] refactor workflow engine from type erasure to typed engines (#16973)

This commit is contained in:
Simo Lin
2026-01-12 10:47:00 -08:00
committed by GitHub
parent fa51b85466
commit ed729d22b3
36 changed files with 803 additions and 917 deletions
+10 -41
View File
@@ -20,16 +20,11 @@ use tokio::{signal, spawn};
use tracing::{debug, error, info, warn, Level};
use crate::{
app_context::{AppContext, AppWorkflowEngine},
app_context::AppContext,
config::{RouterConfig, RoutingMode},
core::{
job_queue::{JobQueue, JobQueueConfig},
steps::{
create_external_worker_workflow, create_local_worker_workflow,
create_mcp_registration_workflow, create_tokenizer_registration_workflow,
create_wasm_module_registration_workflow, create_wasm_module_removal_workflow,
create_worker_removal_workflow, create_worker_update_workflow,
},
steps::WorkflowEngines,
worker::WorkerType,
worker_manager::WorkerManager,
Job,
@@ -730,44 +725,18 @@ pub async fn startup(config: ServerConfig) -> Result<(), Box<dyn std::error::Err
.set(worker_job_queue)
.expect("JobQueue should only be initialized once");
// Initialize workflow engine and register workflows
let engine = Arc::new(AppWorkflowEngine::new());
// Initialize typed workflow engines
let engines = WorkflowEngines::new(&config.router_config);
engine
.event_bus()
.subscribe(Arc::new(LoggingSubscriber))
.await;
// Subscribe logging to all workflow engines
engines.subscribe_all(Arc::new(LoggingSubscriber)).await;
engine
.register_workflow(create_local_worker_workflow(&config.router_config))
.expect("local_worker_registration workflow should be valid");
engine
.register_workflow(create_external_worker_workflow())
.expect("external_worker_registration workflow should be valid");
engine
.register_workflow(create_worker_removal_workflow())
.expect("worker_removal workflow should be valid");
engine
.register_workflow(create_worker_update_workflow())
.expect("worker_update workflow should be valid");
engine
.register_workflow(create_mcp_registration_workflow())
.expect("mcp_registration workflow should be valid");
engine
.register_workflow(create_wasm_module_registration_workflow())
.expect("wasm_module_registration workflow should be valid");
engine
.register_workflow(create_wasm_module_removal_workflow())
.expect("wasm_module_removal workflow should be valid");
engine
.register_workflow(create_tokenizer_registration_workflow())
.expect("tokenizer_registration workflow should be valid");
app_context
.workflow_engine
.set(engine)
.expect("WorkflowEngine should only be initialized once");
.workflow_engines
.set(engines)
.expect("WorkflowEngines should only be initialized once");
debug!(
"Workflow engine initialized with worker and MCP registration workflows (health check timeout: {}s)",
"Workflow engines initialized (health check timeout: {}s)",
config.router_config.health_check.timeout_secs
);