From d5b60ad124f2f25c9132613c6b50cb9dc3403984 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 4 Oct 2021 13:28:00 -0600 Subject: [PATCH] Rename zrpc to rpc Co-Authored-By: Max Brunsfeld --- Cargo.lock | 56 ++++++++++++++-------------- crates/buffer/Cargo.toml | 2 +- crates/buffer/src/lib.rs | 2 +- crates/clock/Cargo.toml | 2 +- crates/clock/src/lib.rs | 8 ++-- crates/{zrpc => rpc}/Cargo.toml | 2 +- crates/{zrpc => rpc}/build.rs | 0 crates/{zrpc => rpc}/proto/zed.proto | 0 crates/{zrpc => rpc}/src/auth.rs | 0 crates/{zrpc => rpc}/src/conn.rs | 0 crates/{zrpc => rpc}/src/lib.rs | 0 crates/{zrpc => rpc}/src/peer.rs | 0 crates/{zrpc => rpc}/src/proto.rs | 0 crates/rpc_client/Cargo.toml | 2 +- crates/rpc_client/src/lib.rs | 12 +++--- crates/rpc_client/src/test.rs | 2 +- crates/server/Cargo.toml | 2 +- crates/server/src/auth.rs | 2 +- crates/server/src/main.rs | 2 +- crates/server/src/rpc.rs | 6 +-- crates/server/src/rpc/store.rs | 2 +- crates/worktree/Cargo.toml | 4 +- crates/worktree/src/lib.rs | 3 +- crates/zed/Cargo.toml | 6 +-- crates/zed/src/channel.rs | 10 ++--- crates/zed/src/user.rs | 3 +- 26 files changed, 62 insertions(+), 66 deletions(-) rename crates/{zrpc => rpc}/Cargo.toml (97%) rename crates/{zrpc => rpc}/build.rs (100%) rename crates/{zrpc => rpc}/proto/zed.proto (100%) rename crates/{zrpc => rpc}/src/auth.rs (100%) rename crates/{zrpc => rpc}/src/conn.rs (100%) rename crates/{zrpc => rpc}/src/lib.rs (100%) rename crates/{zrpc => rpc}/src/peer.rs (100%) rename crates/{zrpc => rpc}/src/proto.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index bdd8bf26c4f46f5d07ded3fd3a81194e3cbd41ef..27e45aa38c8b96c5184fab279fba5b1a092388c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -754,6 +754,7 @@ dependencies = [ "log", "parking_lot", "rand 0.8.3", + "rpc", "seahash", "serde 1.0.125", "similar", @@ -762,7 +763,6 @@ dependencies = [ "tree-sitter", "tree-sitter-rust", "unindent", - "zrpc", ] [[package]] @@ -1025,8 +1025,8 @@ dependencies = [ name = "clock" version = "0.1.0" dependencies = [ + "rpc", "smallvec", - "zrpc", ] [[package]] @@ -4087,6 +4087,28 @@ dependencies = [ "xmlparser", ] +[[package]] +name = "rpc" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-lock", + "async-tungstenite", + "base64 0.13.0", + "futures", + "log", + "parking_lot", + "postage", + "prost", + "prost-build", + "rand 0.8.3", + "rsa", + "serde 1.0.125", + "smol", + "tempdir", + "zstd", +] + [[package]] name = "rpc_client" version = "0.1.0" @@ -4100,12 +4122,12 @@ dependencies = [ "parking_lot", "postage", "rand 0.8.3", + "rpc", "smol", "surf", "thiserror", "tiny_http", "util", - "zrpc", ] [[package]] @@ -5949,6 +5971,7 @@ dependencies = [ "parking_lot", "postage", "rand 0.8.3", + "rpc", "rpc_client", "serde 1.0.125", "serde_json 1.0.64", @@ -5957,7 +5980,6 @@ dependencies = [ "tempdir", "toml 0.5.8", "util", - "zrpc", ] [[package]] @@ -6025,6 +6047,7 @@ dependencies = [ "parking_lot", "postage", "rand 0.8.3", + "rpc", "rpc_client", "rsa", "rust-embed", @@ -6047,7 +6070,6 @@ dependencies = [ "url", "util", "worktree", - "zrpc", ] [[package]] @@ -6076,6 +6098,7 @@ dependencies = [ "parking_lot", "postage", "rand 0.8.3", + "rpc", "rust-embed", "scrypt", "serde 1.0.125", @@ -6088,7 +6111,6 @@ dependencies = [ "time 0.2.25", "toml 0.5.8", "zed", - "zrpc", ] [[package]] @@ -6112,28 +6134,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zrpc" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-lock", - "async-tungstenite", - "base64 0.13.0", - "futures", - "log", - "parking_lot", - "postage", - "prost", - "prost-build", - "rand 0.8.3", - "rsa", - "serde 1.0.125", - "smol", - "tempdir", - "zstd", -] - [[package]] name = "zstd" version = "0.9.0+zstd.1.5.0" diff --git a/crates/buffer/Cargo.toml b/crates/buffer/Cargo.toml index 48bfa8d14b4cc03de74332d68072e1321301e6f4..a5fb5e9c549eae3cf67cd6c79ecd0653aa697b69 100644 --- a/crates/buffer/Cargo.toml +++ b/crates/buffer/Cargo.toml @@ -21,7 +21,7 @@ similar = "1.3" smallvec = { version = "1.6", features = ["union"] } sum_tree = { path = "../sum_tree" } tree-sitter = "0.19.5" -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } [dev-dependencies] rand = "0.8.3" diff --git a/crates/buffer/src/lib.rs b/crates/buffer/src/lib.rs index 07865af34c02bceee661e4e6c086698590cfe966..a857f47976a4a3eb42b60bab4922f9390f5a7545 100644 --- a/crates/buffer/src/lib.rs +++ b/crates/buffer/src/lib.rs @@ -43,7 +43,7 @@ use std::{ use sum_tree::{self, Bias, FilterCursor, SumTree}; pub use syntax_theme::SyntaxTheme; use tree_sitter::{InputEdit, Parser, QueryCursor}; -use zrpc::proto; +use rpc::proto; pub trait File { fn worktree_id(&self) -> usize; diff --git a/crates/clock/Cargo.toml b/crates/clock/Cargo.toml index 9770b1d7d7621029d4ca93f3269de3d4c2481391..3e5d84935d9ea36ac57e1395c4dab8cf27c64ae7 100644 --- a/crates/clock/Cargo.toml +++ b/crates/clock/Cargo.toml @@ -5,4 +5,4 @@ edition = "2018" [dependencies] smallvec = { version = "1.6", features = ["union"] } -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } diff --git a/crates/clock/src/lib.rs b/crates/clock/src/lib.rs index 96418131f2a96410b989367dae0c1ccd613e3be7..ee5c0dba03a969c20ae6b7a252fa5717bb978c5a 100644 --- a/crates/clock/src/lib.rs +++ b/crates/clock/src/lib.rs @@ -61,8 +61,8 @@ impl<'a> AddAssign<&'a Local> for Local { #[derive(Clone, Default, Hash, Eq, PartialEq)] pub struct Global(SmallVec<[Local; 3]>); -impl From> for Global { - fn from(message: Vec) -> Self { +impl From> for Global { + fn from(message: Vec) -> Self { let mut version = Self::new(); for entry in message { version.observe(Local { @@ -74,11 +74,11 @@ impl From> for Global { } } -impl<'a> From<&'a Global> for Vec { +impl<'a> From<&'a Global> for Vec { fn from(version: &'a Global) -> Self { version .iter() - .map(|entry| zrpc::proto::VectorClockEntry { + .map(|entry| rpc::proto::VectorClockEntry { replica_id: entry.replica_id as u32, timestamp: entry.value, }) diff --git a/crates/zrpc/Cargo.toml b/crates/rpc/Cargo.toml similarity index 97% rename from crates/zrpc/Cargo.toml rename to crates/rpc/Cargo.toml index 96f3604e76c76f049dbff0068a8e5caf7eebf0cc..8f43a28a3b4d1fdf191def736621e653fd9fb984 100644 --- a/crates/zrpc/Cargo.toml +++ b/crates/rpc/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Shared logic for communication between the Zed app and the zed.dev server" edition = "2018" -name = "zrpc" +name = "rpc" version = "0.1.0" [features] diff --git a/crates/zrpc/build.rs b/crates/rpc/build.rs similarity index 100% rename from crates/zrpc/build.rs rename to crates/rpc/build.rs diff --git a/crates/zrpc/proto/zed.proto b/crates/rpc/proto/zed.proto similarity index 100% rename from crates/zrpc/proto/zed.proto rename to crates/rpc/proto/zed.proto diff --git a/crates/zrpc/src/auth.rs b/crates/rpc/src/auth.rs similarity index 100% rename from crates/zrpc/src/auth.rs rename to crates/rpc/src/auth.rs diff --git a/crates/zrpc/src/conn.rs b/crates/rpc/src/conn.rs similarity index 100% rename from crates/zrpc/src/conn.rs rename to crates/rpc/src/conn.rs diff --git a/crates/zrpc/src/lib.rs b/crates/rpc/src/lib.rs similarity index 100% rename from crates/zrpc/src/lib.rs rename to crates/rpc/src/lib.rs diff --git a/crates/zrpc/src/peer.rs b/crates/rpc/src/peer.rs similarity index 100% rename from crates/zrpc/src/peer.rs rename to crates/rpc/src/peer.rs diff --git a/crates/zrpc/src/proto.rs b/crates/rpc/src/proto.rs similarity index 100% rename from crates/zrpc/src/proto.rs rename to crates/rpc/src/proto.rs diff --git a/crates/rpc_client/Cargo.toml b/crates/rpc_client/Cargo.toml index 89695fda4c4e7221d60d1ee99f47d512c1afd6df..384a8e56ea3f4201a6ba38aff1a6e21311566fd4 100644 --- a/crates/rpc_client/Cargo.toml +++ b/crates/rpc_client/Cargo.toml @@ -21,4 +21,4 @@ surf = "2.2" thiserror = "1.0.29" tiny_http = "0.8" util = { path = "../util" } -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } diff --git a/crates/rpc_client/src/lib.rs b/crates/rpc_client/src/lib.rs index 097fe1e66dd5248474f0643f5098a63fe3b76f40..b62697b19593738ac4bbb05c9ff4fd3cb7f563fc 100644 --- a/crates/rpc_client/src/lib.rs +++ b/crates/rpc_client/src/lib.rs @@ -12,6 +12,7 @@ use lazy_static::lazy_static; use parking_lot::RwLock; use postage::{prelude::Stream, watch}; use rand::prelude::*; +use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, RequestMessage}; use std::{ any::TypeId, collections::HashMap, @@ -24,11 +25,8 @@ use std::{ use surf::Url; use thiserror::Error; use util::ResultExt; -pub use zrpc::{proto, ConnectionId, PeerId, TypedEnvelope}; -use zrpc::{ - proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, RequestMessage}, - Connection, Peer, Receipt, -}; + +pub use rpc::*; lazy_static! { static ref ZED_SERVER_URL: String = @@ -506,7 +504,7 @@ impl Client { "Authorization", format!("{} {}", credentials.user_id, credentials.access_token), ) - .header("X-Zed-Protocol-Version", zrpc::PROTOCOL_VERSION); + .header("X-Zed-Protocol-Version", rpc::PROTOCOL_VERSION); cx.background().spawn(async move { if let Some(host) = ZED_SERVER_URL.strip_prefix("https://") { let stream = smol::net::TcpStream::connect(host).await?; @@ -536,7 +534,7 @@ impl Client { // zed server to encrypt the user's access token, so that it can'be intercepted by // any other app running on the user's device. let (public_key, private_key) = - zrpc::auth::keypair().expect("failed to generate keypair for auth"); + rpc::auth::keypair().expect("failed to generate keypair for auth"); let public_key_string = String::try_from(public_key).expect("failed to serialize public key for auth"); diff --git a/crates/rpc_client/src/test.rs b/crates/rpc_client/src/test.rs index 055c5c1f8a4f665c92b977cf3e47ab45169dae24..ec4a30465c2cd5d1f58c290895b2352bd957af6c 100644 --- a/crates/rpc_client/src/test.rs +++ b/crates/rpc_client/src/test.rs @@ -5,11 +5,11 @@ use super::Client; use gpui::TestAppContext; use parking_lot::Mutex; use postage::{mpsc, prelude::Stream}; +use rpc::{proto, ConnectionId, Peer, Receipt, TypedEnvelope}; use std::sync::{ atomic::{AtomicBool, AtomicUsize}, Arc, }; -use zrpc::{proto, ConnectionId, Peer, Receipt, TypedEnvelope}; pub struct FakeServer { peer: Arc, diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index b295ff21acf4d7d578b1f5a2ba4ccfed234684eb..d5be7c8661e111710418bf457e0368c64d89978f 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -41,7 +41,7 @@ tide = "0.16.0" tide-compress = "0.9.0" time = "0.2" toml = "0.5.8" -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } [dependencies.async-sqlx-session] version = "0.3.0" diff --git a/crates/server/src/auth.rs b/crates/server/src/auth.rs index 4a06c642eb2554128b06e477c1e934a1fde83b36..2e2f40fca731ff993464e6b5554acc1afcdd418b 100644 --- a/crates/server/src/auth.rs +++ b/crates/server/src/auth.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; use std::{borrow::Cow, convert::TryFrom, sync::Arc}; use surf::{StatusCode, Url}; use tide::{log, Error, Server}; -use zrpc::auth as zed_auth; +use rpc::auth as zed_auth; static CURRENT_GITHUB_USER: &'static str = "current_github_user"; static GITHUB_AUTH_URL: &'static str = "https://github.com/login/oauth/authorize"; diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 49b9a76cf9977169b29daf5d1062f6a505c32303..b6b3ffc23642df9458088b3475f8ccdaf7775c66 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use surf::http::cookies::SameSite; use tide::{log, sessions::SessionMiddleware}; use tide_compress::CompressMiddleware; -use zrpc::Peer; +use rpc::Peer; type Request = tide::Request>; diff --git a/crates/server/src/rpc.rs b/crates/server/src/rpc.rs index dbb8b02f6338134855a6b800a60c9f76790cee4c..3012d17db6b2429c6e6966cbb68da2a6b48380dd 100644 --- a/crates/server/src/rpc.rs +++ b/crates/server/src/rpc.rs @@ -27,7 +27,7 @@ use tide::{ Request, Response, }; use time::OffsetDateTime; -use zrpc::{ +use rpc::{ proto::{self, AnyTypedEnvelope, EnvelopedMessage}, Connection, ConnectionId, Peer, TypedEnvelope, }; @@ -897,7 +897,7 @@ pub fn add_routes(app: &mut tide::Server>, rpc: &Arc) { .header("X-Zed-Protocol-Version") .and_then(|v| v.as_str().parse().ok()); - if !upgrade_requested || client_protocol_version != Some(zrpc::PROTOCOL_VERSION) { + if !upgrade_requested || client_protocol_version != Some(rpc::PROTOCOL_VERSION) { return Ok(Response::new(StatusCode::UpgradeRequired)); } @@ -988,7 +988,7 @@ mod tests { workspace::Workspace, worktree::Worktree, }; - use zrpc::Peer; + use rpc::Peer; #[gpui::test] async fn test_share_worktree(mut cx_a: TestAppContext, mut cx_b: TestAppContext) { diff --git a/crates/server/src/rpc/store.rs b/crates/server/src/rpc/store.rs index b33cd135589d57de9aaf2602f25c2a58a0f6dfd8..ac9c069146745d48b3820cb4275895d973549e2c 100644 --- a/crates/server/src/rpc/store.rs +++ b/crates/server/src/rpc/store.rs @@ -1,7 +1,7 @@ use crate::db::{ChannelId, UserId}; use anyhow::anyhow; use std::collections::{hash_map, HashMap, HashSet}; -use zrpc::{proto, ConnectionId}; +use rpc::{proto, ConnectionId}; #[derive(Default)] pub struct Store { diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 592f2908e927ffd29b0b7563b4da9a3fd9192c1e..4d9d4be4a120bfecf2d559503150926d48d2159c 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -28,11 +28,11 @@ smol = "1.2.5" sum_tree = { path = "../sum_tree" } util = { path = "../util" } toml = "0.5" -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } [dev-dependencies] rand = "0.8.3" rpc_client = { path = "../rpc_client", features = ["test-support"] } tempdir = { version = "0.3.7" } util = { path = "../util", features = ["test-support"] } -zrpc = { path = "../zrpc", features = ["test-support"] } +rpc = { path = "../rpc", features = ["test-support"] } diff --git a/crates/worktree/src/lib.rs b/crates/worktree/src/lib.rs index d284ba376bd64184ea63762b1c1c559092465129..3803401ed76b8aabc2dbc2a4b8ea00bc982148ad 100644 --- a/crates/worktree/src/lib.rs +++ b/crates/worktree/src/lib.rs @@ -19,7 +19,7 @@ use postage::{ prelude::{Sink as _, Stream as _}, watch, }; -use rpc_client as rpc; +use rpc_client::{self as rpc, proto, PeerId, TypedEnvelope}; use serde::Deserialize; use smol::channel::{self, Sender}; use std::{ @@ -41,7 +41,6 @@ use std::{ use sum_tree::Bias; use sum_tree::{self, Edit, SeekTarget, SumTree}; use util::TryFutureExt; -use zrpc::{proto, PeerId, TypedEnvelope}; lazy_static! { static ref GITIGNORE: &'static OsStr = OsStr::new(".gitignore"); diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 0eb5e764d84a3859df00dfd0afe365c006bc8b51..def8af297fa6f58b2b700bfd84a82d3550d9c9df 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -20,7 +20,7 @@ test-support = [ "rpc_client/test-support", "tempdir", "worktree/test-support", - "zrpc/test-support", + "rpc/test-support", ] [dependencies] @@ -71,7 +71,7 @@ tree-sitter-rust = "0.19.0" url = "2.2" util = { path = "../util" } worktree = { path = "../worktree" } -zrpc = { path = "../zrpc" } +rpc = { path = "../rpc" } [dev-dependencies] cargo-bundle = "0.5.0" @@ -84,7 +84,7 @@ gpui = { path = "../gpui", features = ["test-support"] } rpc_client = { path = "../rpc_client", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } worktree = { path = "../worktree", features = ["test-support"] } -zrpc = { path = "../zrpc", features = ["test-support"] } +rpc = { path = "../rpc", features = ["test-support"] } [package.metadata.bundle] icon = ["app-icon@2x.png", "app-icon.png"] diff --git a/crates/zed/src/channel.rs b/crates/zed/src/channel.rs index 3da50032e92d091e22376bfc78407728b0b2ae43..48ecbb9fa21c7c7b0736b219731c283283e900b3 100644 --- a/crates/zed/src/channel.rs +++ b/crates/zed/src/channel.rs @@ -5,7 +5,11 @@ use gpui::{ }; use postage::prelude::Stream; use rand::prelude::*; -use rpc_client as rpc; +use rpc_client::{ + self as rpc, + proto::{self, ChannelMessageSent}, + TypedEnvelope, +}; use std::{ collections::{HashMap, HashSet}, mem, @@ -15,10 +19,6 @@ use std::{ use sum_tree::{self, Bias, SumTree}; use time::OffsetDateTime; use util::{post_inc, TryFutureExt}; -use zrpc::{ - proto::{self, ChannelMessageSent}, - TypedEnvelope, -}; pub struct ChannelList { available_channels: Option>, diff --git a/crates/zed/src/user.rs b/crates/zed/src/user.rs index 63718345b767ab46abd4883fb21feae508dcba39..106cbd7ba0b792f6c7b02a9f2ae3b5087f9d6fa3 100644 --- a/crates/zed/src/user.rs +++ b/crates/zed/src/user.rs @@ -3,13 +3,12 @@ use anyhow::{anyhow, Context, Result}; use futures::future; use gpui::{AsyncAppContext, Entity, ImageData, ModelContext, ModelHandle, Task}; use postage::{prelude::Stream, sink::Sink, watch}; -use rpc_client as rpc; +use rpc_client::{self as rpc, proto, TypedEnvelope}; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; use util::TryFutureExt as _; -use zrpc::{proto, TypedEnvelope}; #[derive(Debug)] pub struct User {