Skip to content

Commit

Permalink
Bump collab min version to 0.134 (zed-industries#16918)
Browse files Browse the repository at this point in the history
0.05% of requests use a version less than this today; and it lets us get
  rid of a bunch of versioning we no longer need.

Release Notes:

- N/A
  • Loading branch information
ConradIrwin authored Aug 28, 2024
1 parent cfc3b7d commit 22a791d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 70 deletions.
45 changes: 2 additions & 43 deletions crates/collab/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ use tracing::{
info_span, instrument, Instrument,
};

use self::connection_pool::VersionedMessage;

pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);

// kubernetes gives terminated pods 10s to shutdown gracefully. After they're gone, we can clean up old resources.
Expand Down Expand Up @@ -507,7 +505,7 @@ impl Server {
forward_mutating_project_request::<proto::ApplyCompletionAdditionalEdits>,
))
.add_request_handler(user_handler(
forward_versioned_mutating_project_request::<proto::OpenNewBuffer>,
forward_mutating_project_request::<proto::OpenNewBuffer>,
))
.add_request_handler(user_handler(
forward_mutating_project_request::<proto::ResolveCompletionDocumentation>,
Expand Down Expand Up @@ -549,7 +547,7 @@ impl Server {
forward_mutating_project_request::<proto::OnTypeFormatting>,
))
.add_request_handler(user_handler(
forward_versioned_mutating_project_request::<proto::SaveBuffer>,
forward_mutating_project_request::<proto::SaveBuffer>,
))
.add_request_handler(user_handler(
forward_mutating_project_request::<proto::BlameBuffer>,
Expand Down Expand Up @@ -3047,45 +3045,6 @@ where
Ok(())
}

/// forward a project request to the host. These requests are disallowed
/// for guests.
async fn forward_versioned_mutating_project_request<T>(
request: T,
response: Response<T>,
session: UserSession,
) -> Result<()>
where
T: EntityMessage + RequestMessage + VersionedMessage,
{
let project_id = ProjectId::from_proto(request.remote_entity_id());

let host_connection_id = session
.db()
.await
.host_for_mutating_project_request(project_id, session.connection_id, session.user_id())
.await?;
if let Some(host_version) = session
.connection_pool()
.await
.connection(host_connection_id)
.map(|c| c.zed_version)
{
if let Some(min_required_version) = request.required_host_version() {
if min_required_version > host_version {
return Err(anyhow!(ErrorCode::RemoteUpgradeRequired
.with_tag("required", &min_required_version.to_string())))?;
}
}
}

let payload = session
.peer
.forward_request(session.connection_id, host_connection_id, request)
.await?;
response.send(payload)?;
Ok(())
}

/// Notify other participants that a new buffer has been created
async fn create_buffer_for_peer(
request: proto::CreateBufferForPeer,
Expand Down
28 changes: 1 addition & 27 deletions crates/collab/src/rpc/connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ impl fmt::Display for ZedVersion {

impl ZedVersion {
pub fn can_collaborate(&self) -> bool {
self.0 >= SemanticVersion::new(0, 129, 2)
}

pub fn with_save_as() -> ZedVersion {
ZedVersion(SemanticVersion::new(0, 134, 0))
self.0 >= SemanticVersion::new(0, 134, 0)
}

pub fn with_list_directory() -> ZedVersion {
Expand All @@ -48,28 +44,6 @@ impl ZedVersion {
}
}

pub trait VersionedMessage {
fn required_host_version(&self) -> Option<ZedVersion> {
None
}
}

impl VersionedMessage for proto::SaveBuffer {
fn required_host_version(&self) -> Option<ZedVersion> {
if self.new_path.is_some() {
Some(ZedVersion::with_save_as())
} else {
None
}
}
}

impl VersionedMessage for proto::OpenNewBuffer {
fn required_host_version(&self) -> Option<ZedVersion> {
Some(ZedVersion::with_save_as())
}
}

#[derive(Serialize)]
pub struct Connection {
pub principal_id: PrincipalId,
Expand Down

0 comments on commit 22a791d

Please sign in to comment.