feat(runtime): cache compiled components

Enable Wasmtime's persistent compilation cache and expose an optional cache directory in RuntimeConfig.

Create and canonicalize the configured directory before Engine construction, and report cache filesystem and configuration failures through dedicated RuntimeError variants.
This commit is contained in:
Maofeng
2026-07-30 07:18:21 +08:00
parent 38a397fa20
commit 53a8c6b690
4 changed files with 132 additions and 21 deletions
+11 -1
View File
@@ -1,6 +1,6 @@
//! Runtime error taxonomy exposed to management layers.
use std::time::Duration;
use std::{path::PathBuf, time::Duration};
use thiserror::Error;
@@ -36,6 +36,16 @@ pub enum RuntimeError {
#[error("runtime creation failed: {0}")]
RuntimeCreation(#[source] wasmtime::Error),
#[error("failed to prepare Component compilation cache {path}: {source}")]
CacheDirectory {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("invalid Component compilation cache configuration: {0}")]
CacheConfiguration(#[source] wasmtime::Error),
#[error("failed to read component artifact {path}: {source}")]
ArtifactRead {
path: String,