Share remote environment exec-server client

Create one lazy exec-server client per remote environment and pass clones into the remote process and filesystem backends. This keeps ExecServerClient as the connected-client type while avoiding duplicate websocket clients for one environment.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-21 11:13:27 -07:00
parent 154be3fc66
commit 0642d36ae4
3 changed files with 8 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ use std::sync::Arc;
use crate::ExecServerError;
use crate::ExecServerRuntimePaths;
use crate::client::LazyRemoteExecServerClient;
use crate::file_system::ExecutorFileSystem;
use crate::local_file_system::LocalFileSystem;
use crate::local_process::LocalProcess;
@@ -196,10 +197,9 @@ impl Environment {
exec_server_url: String,
local_runtime_paths: Option<ExecServerRuntimePaths>,
) -> Self {
let exec_backend: Arc<dyn ExecBackend> =
Arc::new(RemoteProcess::new(exec_server_url.clone()));
let filesystem: Arc<dyn ExecutorFileSystem> =
Arc::new(RemoteFileSystem::new(exec_server_url.clone()));
let client = LazyRemoteExecServerClient::new(exec_server_url.clone());
let exec_backend: Arc<dyn ExecBackend> = Arc::new(RemoteProcess::new(client.clone()));
let filesystem: Arc<dyn ExecutorFileSystem> = Arc::new(RemoteFileSystem::new(client));
Self {
exec_server_url: Some(exec_server_url),

View File

@@ -32,11 +32,9 @@ pub(crate) struct RemoteFileSystem {
}
impl RemoteFileSystem {
pub(crate) fn new(websocket_url: String) -> Self {
pub(crate) fn new(client: LazyRemoteExecServerClient) -> Self {
trace!("remote fs new");
Self {
client: LazyRemoteExecServerClient::new(websocket_url),
}
Self { client }
}
}

View File

@@ -25,11 +25,9 @@ struct RemoteExecProcess {
}
impl RemoteProcess {
pub(crate) fn new(websocket_url: String) -> Self {
pub(crate) fn new(client: LazyRemoteExecServerClient) -> Self {
trace!("remote process new");
Self {
client: LazyRemoteExecServerClient::new(websocket_url),
}
Self { client }
}
}