feat: materialize execution workspaces
This commit is contained in:
@@ -14,6 +14,7 @@ use std::process::ExitCode;
|
||||
use std::sync::Arc;
|
||||
|
||||
use worker_runtime::error::RuntimeError;
|
||||
use worker_runtime::execution_workspace::LocalGitWorktreeMaterializer;
|
||||
use worker_runtime::fs_store::FsRuntimeStoreOptions;
|
||||
use worker_runtime::http_server::{
|
||||
RuntimeHttpServerConfig, RuntimeHttpServerError, RuntimeHttpStoreSelection,
|
||||
@@ -80,8 +81,14 @@ fn build_runtime(config: &ProcessConfig) -> Result<Runtime, ProcessError> {
|
||||
if let Some(profile) = config.profile.clone() {
|
||||
factory = factory.with_profile(profile);
|
||||
}
|
||||
let backend =
|
||||
Arc::new(WorkerRuntimeExecutionBackend::new(factory).map_err(ProcessError::WorkerAdapter)?);
|
||||
let execution_workspace_root = execution_workspace_runtime_root(config);
|
||||
let backend = Arc::new(
|
||||
WorkerRuntimeExecutionBackend::new(factory)
|
||||
.map_err(ProcessError::WorkerAdapter)?
|
||||
.with_execution_workspace_materializer(LocalGitWorktreeMaterializer::new(
|
||||
execution_workspace_root,
|
||||
)),
|
||||
);
|
||||
|
||||
match &config.http.store {
|
||||
RuntimeHttpStoreSelection::Memory => {
|
||||
@@ -102,6 +109,16 @@ fn build_runtime(config: &ProcessConfig) -> Result<Runtime, ProcessError> {
|
||||
}
|
||||
}
|
||||
|
||||
fn execution_workspace_runtime_root(config: &ProcessConfig) -> PathBuf {
|
||||
match &config.http.store {
|
||||
RuntimeHttpStoreSelection::Fs { root } => root.clone(),
|
||||
_ => config
|
||||
.worker_runtime_base_dir
|
||||
.clone()
|
||||
.unwrap_or_else(|| env::temp_dir().join("yoi-worker-runtime")),
|
||||
}
|
||||
}
|
||||
|
||||
fn runtime_options_from_http(config: &RuntimeHttpServerConfig) -> RuntimeOptions {
|
||||
RuntimeOptions {
|
||||
runtime_id: config.runtime_id.clone(),
|
||||
|
||||
Reference in New Issue
Block a user