use zlayer_spec::ServiceType;
use super::WasmPipelineConfig;
pub struct WasmPipelineRuntime {
config: WasmPipelineConfig,
}
impl WasmPipelineRuntime {
pub fn new(
config: WasmPipelineConfig,
) -> Result<Self, Box<dyn std::error::Error + Send + Sync>> {
tracing::info!(
service_type = ?config.service_type,
"created WASM pipeline runtime"
);
Ok(Self { config })
}
#[must_use]
pub fn service_type(&self) -> ServiceType {
self.config.service_type
}
#[must_use]
pub fn pipeline_stage(&self) -> &'static str {
match self.config.service_type {
ServiceType::WasmTransformer => "transform",
ServiceType::WasmAuthenticator => "authenticate",
ServiceType::WasmRateLimiter => "rate_limit",
ServiceType::WasmMiddleware => "middleware",
ServiceType::WasmRouter => "route",
_ => "unknown",
}
}
#[must_use]
pub fn config(&self) -> &WasmPipelineConfig {
&self.config
}
}