mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
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:
@@ -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),
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user