[model-gateway] fix left over sgl-router names to sgl-model-gateway (#14512)

This commit is contained in:
Simo Lin
2025-12-05 12:41:48 -08:00
committed by GitHub
parent 49dfa1d891
commit aed835e32d
16 changed files with 55 additions and 55 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# WASM Guest Examples for sgl-router
# WASM Guest Examples for sgl-model-gateway
This directory contains example WASM middleware components demonstrating how to implement custom middleware for sgl-router using the WebAssembly Component Model.
This directory contains example WASM middleware components demonstrating how to implement custom middleware for sgl-model-gateway using the WebAssembly Component Model.
## Examples Overview
@@ -56,7 +56,7 @@ All examples require:
- Rust toolchain (latest stable)
- `wasm32-wasip2` target: `rustup target add wasm32-wasip2`
- `wasm-tools`: `cargo install wasm-tools`
- sgl-router running with WASM enabled (`--enable-wasm`)
- sgl-model-gateway running with WASM enabled (`--enable-wasm`)
## Building All Examples
@@ -1,6 +1,6 @@
# WASM Auth Example for sgl-router
# WASM Auth Example for sgl-model-gateway
This example demonstrates API key authentication middleware for sgl-router using the WebAssembly Component Model.
This example demonstrates API key authentication middleware for sgl-model-gateway using the WebAssembly Component Model.
## Overview
@@ -1,6 +1,6 @@
# WASM Logging Example for sgl-router
# WASM Logging Example for sgl-model-gateway
This example demonstrates logging and tracing middleware for sgl-router using the WebAssembly Component Model.
This example demonstrates logging and tracing middleware for sgl-model-gateway using the WebAssembly Component Model.
## Overview
@@ -1,6 +1,6 @@
# WASM Rate Limit Example for sgl-router
# WASM Rate Limit Example for sgl-model-gateway
This example demonstrates rate limiting middleware for sgl-router using the WebAssembly Component Model.
This example demonstrates rate limiting middleware for sgl-model-gateway using the WebAssembly Component Model.
## Overview
+1 -1
View File
@@ -28,7 +28,7 @@ use crate::{
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
spec::{
apply_modify_action_to_headers, build_wasm_headers_from_axum_headers,
sgl::router::middleware_types::{
sgl::model_gateway::middleware_types::{
Action, Request as WasmRequest, Response as WasmResponse,
},
},
+8 -8
View File
@@ -1,10 +1,10 @@
# WebAssembly (WASM) Extensibility for sgl-router
# WebAssembly (WASM) Extensibility for sgl-model-gateway
This module provides WebAssembly-based extensibility for sgl-router, enabling dynamic, safe, and portable middleware execution without requiring router restarts or recompilation.
This module provides WebAssembly-based extensibility for sgl-model-gateway, enabling dynamic, safe, and portable middleware execution without requiring router restarts or recompilation.
## Overview
The WASM module allows you to extend sgl-router functionality by deploying WebAssembly components that can:
The WASM module allows you to extend sgl-model-gateway functionality by deploying WebAssembly components that can:
- **Intercept requests/responses** at various lifecycle points (OnRequest, OnResponse)
- **Modify HTTP headers and bodies** before/after processing
@@ -68,7 +68,7 @@ See [`interface/`](./interface/) for the complete interface definition.
### Prerequisites
- sgl-router compiled with WASM support
- sgl-model-gateway compiled with WASM support
- Rust toolchain (for building WASM components)
- `wasm32-wasip2` target: `rustup target add wasm32-wasip2`
- `wasm-tools`: `cargo install wasm-tools`
@@ -78,7 +78,7 @@ See [`interface/`](./interface/) for the complete interface definition.
Enable WASM support when starting the router:
```bash
./sgl-router --enable-wasm --worker-urls=http://0.0.0.0:30000 --port=3000
./sgl-model-gateway --enable-wasm --worker-urls=http://0.0.0.0:30000 --port=3000
```
### Deploying a WASM Module
@@ -208,11 +208,11 @@ Define your component using the WASM interface from `interface/spec.*`:
```rust
wit_bindgen::generate!({
path: "../../../src/wasm/interface",
world: "sgl-router",
world: "sgl-model-gateway",
});
use exports::sgl::router::middleware_on_request::Guest as OnRequestGuest;
use sgl::router::middleware_types::{Request, Action};
use exports::sgl::model_gateway::middleware_on_request::Guest as OnRequestGuest;
use sgl::model_gateway::middleware_types::{Request, Action};
struct Middleware;
@@ -1,4 +1,4 @@
package sgl:router;
package sgl:model-gateway;
interface middleware-types {
record header { name: string, value: string }
@@ -48,7 +48,7 @@ interface middleware-on-response {
on-response: func(resp: response) -> action;
}
world sgl-router {
world sgl-model-gateway {
export middleware-on-request;
export middleware-on-response;
}
+1 -1
View File
@@ -1,4 +1,4 @@
//! WebAssembly (WASM) module support for sgl-router
//! WebAssembly (WASM) module support for sgl-model-gateway
//!
//! This module provides WASM component execution capabilities using the WebAssembly Component Model.
//! It supports middleware execution at various attach points (OnRequest, OnResponse) with async support.
+1 -1
View File
@@ -227,7 +227,7 @@ impl WasmModuleManager {
module: &WasmModule,
attach_point: WasmModuleAttachPoint,
input: WasmComponentInput,
) -> Option<crate::wasm::spec::sgl::router::middleware_types::Action> {
) -> Option<crate::wasm::spec::sgl::model_gateway::middleware_types::Action> {
use tracing::error;
let action_result = self
+5 -5
View File
@@ -20,7 +20,7 @@ use crate::wasm::{
config::WasmRuntimeConfig,
errors::{Result, WasmError, WasmRuntimeError},
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
spec::SglRouter,
spec::SglModelGateway,
types::{WasiState, WasmComponentInput, WasmComponentOutput},
};
@@ -322,7 +322,7 @@ impl WasmThreadPool {
};
// Instantiate component (must use async instantiation when async support is enabled)
let bindings = SglRouter::instantiate_async(&mut store, &component, &linker)
let bindings = SglModelGateway::instantiate_async(&mut store, &component, &linker)
.await
.map_err(|e| {
WasmError::from(WasmRuntimeError::InstanceCreateFailed(e.to_string()))
@@ -330,7 +330,7 @@ impl WasmThreadPool {
// Call on-request (async call when async support is enabled)
let action_result = bindings
.sgl_router_middleware_on_request()
.sgl_model_gateway_middleware_on_request()
.call_on_request(&mut store, &request)
.await
.map_err(|e| WasmError::from(WasmRuntimeError::CallFailed(e.to_string())))?;
@@ -350,7 +350,7 @@ impl WasmThreadPool {
};
// Instantiate component (must use async instantiation when async support is enabled)
let bindings = SglRouter::instantiate_async(&mut store, &component, &linker)
let bindings = SglModelGateway::instantiate_async(&mut store, &component, &linker)
.await
.map_err(|e| {
WasmError::from(WasmRuntimeError::InstanceCreateFailed(e.to_string()))
@@ -358,7 +358,7 @@ impl WasmThreadPool {
// Call on-response (async call when async support is enabled)
let action_result = bindings
.sgl_router_middleware_on_response()
.sgl_model_gateway_middleware_on_response()
.call_on_response(&mut store, &response)
.await
.map_err(|e| WasmError::from(WasmRuntimeError::CallFailed(e.to_string())))?;
+4 -4
View File
@@ -7,7 +7,7 @@ use axum::http::{header, HeaderMap, HeaderValue};
wasmtime::component::bindgen!({
path: "src/wasm/interface",
world: "sgl-router",
world: "sgl-model-gateway",
imports: { default: async | trappable },
exports: { default: async },
});
@@ -15,11 +15,11 @@ wasmtime::component::bindgen!({
/// Build WebAssembly headers from Axum HeaderMap
pub fn build_wasm_headers_from_axum_headers(
headers: &HeaderMap,
) -> Vec<sgl::router::middleware_types::Header> {
) -> Vec<sgl::model_gateway::middleware_types::Header> {
let mut wasm_headers = Vec::new();
for (name, value) in headers.iter() {
if let Ok(value_str) = value.to_str() {
wasm_headers.push(sgl::router::middleware_types::Header {
wasm_headers.push(sgl::model_gateway::middleware_types::Header {
name: name.as_str().to_string(),
value: value_str.to_string(),
});
@@ -31,7 +31,7 @@ pub fn build_wasm_headers_from_axum_headers(
/// Apply ModifyAction header modifications to Axum HeaderMap
pub fn apply_modify_action_to_headers(
headers: &mut HeaderMap,
modify: &sgl::router::middleware_types::ModifyAction,
modify: &sgl::model_gateway::middleware_types::ModifyAction,
) {
// Apply headers_set
for header_mod in &modify.headers_set {
+1 -1
View File
@@ -8,7 +8,7 @@ use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView};
use crate::wasm::{
module::{MiddlewareAttachPoint, WasmModuleAttachPoint},
spec::sgl::router::middleware_types,
spec::sgl::model_gateway::middleware_types,
};
/// Generic input type for WASM component execution
+1 -1
View File
@@ -756,7 +756,7 @@ async fn test_wasm_module_execution() {
// Execute the module
use sgl_model_gateway::wasm::{
spec::sgl::router::middleware_types,
spec::sgl::model_gateway::middleware_types,
types::{WasmComponentInput, WasmComponentOutput},
};