Extract a BufferStore object from Project (#14037)
This is a ~small~ pure refactor that's a step toward SSH remoting. I've extracted the Project's buffer state management into a smaller, separate struct called `BufferStore`, currently in the same crate. I did this as a separate PR to reduce conflicts between main and `remoting-over-ssh`. The idea is to make use of this struct (and other smaller structs that make up `Project`) in a dedicated, simpler `HeadlessProject` type that we will use in the SSH server to model the remote end of a project. With this approach, as we develop the headless project, we can avoid adding more conditional logic to `Project` itself (which is already very complex), and actually make `Project` a bit smaller by extracting out helper objects. Release Notes: - N/A
This commit is contained in:
parent
21c5ce2bbd
commit
489077befc
15 changed files with 1394 additions and 1115 deletions
|
@ -13,8 +13,9 @@ use async_tungstenite::tungstenite::{
|
|||
use clock::SystemClock;
|
||||
use collections::HashMap;
|
||||
use futures::{
|
||||
channel::oneshot, future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, Stream, StreamExt,
|
||||
TryFutureExt as _, TryStreamExt,
|
||||
channel::oneshot,
|
||||
future::{BoxFuture, LocalBoxFuture},
|
||||
AsyncReadExt, FutureExt, SinkExt, Stream, StreamExt, TryFutureExt as _, TryStreamExt,
|
||||
};
|
||||
use gpui::{
|
||||
actions, AnyModel, AnyWeakModel, AppContext, AsyncAppContext, Global, Model, Task, WeakModel,
|
||||
|
@ -23,6 +24,7 @@ use http::{HttpClient, HttpClientWithUrl};
|
|||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
use postage::watch;
|
||||
use proto::ProtoClient;
|
||||
use rand::prelude::*;
|
||||
use release_channel::{AppVersion, ReleaseChannel};
|
||||
use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage};
|
||||
|
@ -1408,6 +1410,11 @@ impl Client {
|
|||
self.peer.send(self.connection_id()?, message)
|
||||
}
|
||||
|
||||
fn send_dynamic(&self, envelope: proto::Envelope) -> Result<()> {
|
||||
let connection_id = self.connection_id()?;
|
||||
self.peer.send_dynamic(connection_id, envelope)
|
||||
}
|
||||
|
||||
pub fn request<T: RequestMessage>(
|
||||
&self,
|
||||
request: T,
|
||||
|
@ -1606,6 +1613,20 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
impl ProtoClient for Client {
|
||||
fn request(
|
||||
&self,
|
||||
envelope: proto::Envelope,
|
||||
request_type: &'static str,
|
||||
) -> BoxFuture<'static, Result<proto::Envelope>> {
|
||||
self.request_dynamic(envelope, request_type).boxed()
|
||||
}
|
||||
|
||||
fn send(&self, envelope: proto::Envelope) -> Result<()> {
|
||||
self.send_dynamic(envelope)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct DevelopmentCredentials {
|
||||
user_id: u64,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue