SSH connection pooling (#19692)
Co-Authored-By: Max <max@zed.dev> Closes #ISSUE Release Notes: - SSH Remoting: Reuse connections across hosts --------- Co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
3a9c071e6e
commit
d45b830412
4 changed files with 686 additions and 541 deletions
|
@ -26,7 +26,7 @@ async fn test_sharing_an_ssh_remote_project(
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Set up project on remote FS
|
// Set up project on remote FS
|
||||||
let (port, server_ssh) = SshRemoteClient::fake_server(cx_a, server_cx);
|
let (opts, server_ssh) = SshRemoteClient::fake_server(cx_a, server_cx);
|
||||||
let remote_fs = FakeFs::new(server_cx.executor());
|
let remote_fs = FakeFs::new(server_cx.executor());
|
||||||
remote_fs
|
remote_fs
|
||||||
.insert_tree(
|
.insert_tree(
|
||||||
|
@ -67,7 +67,7 @@ async fn test_sharing_an_ssh_remote_project(
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let client_ssh = SshRemoteClient::fake_client(port, cx_a).await;
|
let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await;
|
||||||
let (project_a, worktree_id) = client_a
|
let (project_a, worktree_id) = client_a
|
||||||
.build_ssh_project("/code/project1", client_ssh, cx_a)
|
.build_ssh_project("/code/project1", client_ssh, cx_a)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -17,6 +17,7 @@ use gpui::{
|
||||||
use picker::Picker;
|
use picker::Picker;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use remote::SshConnectionOptions;
|
use remote::SshConnectionOptions;
|
||||||
|
use remote::SshRemoteClient;
|
||||||
use settings::update_settings_file;
|
use settings::update_settings_file;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use ui::{
|
use ui::{
|
||||||
|
@ -46,6 +47,7 @@ pub struct RemoteServerProjects {
|
||||||
scroll_handle: ScrollHandle,
|
scroll_handle: ScrollHandle,
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
selectable_items: SelectableItemList,
|
selectable_items: SelectableItemList,
|
||||||
|
retained_connections: Vec<Model<SshRemoteClient>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CreateRemoteServer {
|
struct CreateRemoteServer {
|
||||||
|
@ -355,6 +357,7 @@ impl RemoteServerProjects {
|
||||||
scroll_handle: ScrollHandle::new(),
|
scroll_handle: ScrollHandle::new(),
|
||||||
workspace,
|
workspace,
|
||||||
selectable_items: Default::default(),
|
selectable_items: Default::default(),
|
||||||
|
retained_connections: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +427,7 @@ impl RemoteServerProjects {
|
||||||
let address_editor = editor.clone();
|
let address_editor = editor.clone();
|
||||||
let creating = cx.spawn(move |this, mut cx| async move {
|
let creating = cx.spawn(move |this, mut cx| async move {
|
||||||
match connection.await {
|
match connection.await {
|
||||||
Some(_) => this
|
Some(Some(client)) => this
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
let _ = this.workspace.update(cx, |workspace, _| {
|
let _ = this.workspace.update(cx, |workspace, _| {
|
||||||
workspace
|
workspace
|
||||||
|
@ -432,14 +435,14 @@ impl RemoteServerProjects {
|
||||||
.telemetry()
|
.telemetry()
|
||||||
.report_app_event("create ssh server".to_string())
|
.report_app_event("create ssh server".to_string())
|
||||||
});
|
});
|
||||||
|
this.retained_connections.push(client);
|
||||||
this.add_ssh_server(connection_options, cx);
|
this.add_ssh_server(connection_options, cx);
|
||||||
this.mode = Mode::default_mode();
|
this.mode = Mode::default_mode();
|
||||||
this.selectable_items.reset_selection();
|
this.selectable_items.reset_selection();
|
||||||
cx.notify()
|
cx.notify()
|
||||||
})
|
})
|
||||||
.log_err(),
|
.log_err(),
|
||||||
None => this
|
_ => this
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
address_editor.update(cx, |this, _| {
|
address_editor.update(cx, |this, _| {
|
||||||
this.set_read_only(false);
|
this.set_read_only(false);
|
||||||
|
@ -1056,7 +1059,7 @@ impl RemoteServerProjects {
|
||||||
);
|
);
|
||||||
|
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
if confirmation.await.ok() == Some(1) {
|
if confirmation.await.ok() == Some(0) {
|
||||||
remote_servers
|
remote_servers
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.delete_ssh_server(index, cx);
|
this.delete_ssh_server(index, cx);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -702,7 +702,7 @@ async fn init_test(
|
||||||
) -> (Model<Project>, Model<HeadlessProject>, Arc<FakeFs>) {
|
) -> (Model<Project>, Model<HeadlessProject>, Arc<FakeFs>) {
|
||||||
init_logger();
|
init_logger();
|
||||||
|
|
||||||
let (forwarder, ssh_server_client) = SshRemoteClient::fake_server(cx, server_cx);
|
let (opts, ssh_server_client) = SshRemoteClient::fake_server(cx, server_cx);
|
||||||
let fs = FakeFs::new(server_cx.executor());
|
let fs = FakeFs::new(server_cx.executor());
|
||||||
fs.insert_tree(
|
fs.insert_tree(
|
||||||
"/code",
|
"/code",
|
||||||
|
@ -744,7 +744,7 @@ async fn init_test(
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let ssh = SshRemoteClient::fake_client(forwarder, cx).await;
|
let ssh = SshRemoteClient::fake_client(opts, cx).await;
|
||||||
let project = build_project(ssh, cx);
|
let project = build_project(ssh, cx);
|
||||||
project
|
project
|
||||||
.update(cx, {
|
.update(cx, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue