Skip to content

Commit

Permalink
Remove all protobuf code from the ipc crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Dec 6, 2024
1 parent 189f9d5 commit e3a2479
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 172 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions crates/ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ native-send = ["tokio/process"]

[dependencies]
thiserror.workspace = true
prost.workspace = true
tracing.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand All @@ -26,15 +25,14 @@ parking_lot.workspace = true
sos-sdk = { version = "0.16", path = "../sdk", features = ["account"] }
sos-protocol = { version = "0.16", path = "../protocol" }

tokio = { version = "1", features = ["rt", "rt-multi-thread", "net", "macros", "io-util", "io-std", "sync"] }
tokio-stream = "0.1"
tokio = { version = "1", features = [
"rt", "net", "macros", "io-util", "io-std", "sync"] }
tokio-util = { version = "0.7", features = ["codec"] }
futures-util = { version = "0.3", features = ["sink"] }
interprocess = { version = "2", features = ["tokio"] }

open = { version = "5", optional = true }
once_cell = { workspace = true, optional = true }
pin-project-lite = "0.2"

# HTTP dependencies for local server
http.workspace = true
Expand All @@ -43,10 +41,8 @@ hyper = { version = "1" }
matchit = "0.7"
bytes.workspace = true
http-body-util = "0.1"
hyper-util = "0.1"
hyper-util = { version = "0.1", features = ["tokio"]}

[build-dependencies]
rustc_version = "0.4.1"
prost-build = "0.13"
protoc-bin-vendored = "3"

9 changes: 0 additions & 9 deletions crates/ipc/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate prost_build;
use rustc_version::{version_meta, Channel};

fn main() {
Expand All @@ -12,12 +11,4 @@ fn main() {
Channel::Dev => "CHANNEL_DEV",
};
println!("cargo:rustc-cfg={}", channel);

std::env::set_var(
"PROTOC",
protoc_bin_vendored::protoc_bin_path().unwrap(),
);

prost_build::compile_protos(&["src/protobuf/common.proto"], &["src"])
.unwrap();
}
71 changes: 0 additions & 71 deletions crates/ipc/src/bindings/common.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/ipc/src/bindings/mod.rs

This file was deleted.

12 changes: 0 additions & 12 deletions crates/ipc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ pub enum Error {
#[error("native bridge failed to parse JSON, reason: {0}")]
NativeBridgeJsonParse(String),

/// Error generated by the protobuf library when encoding.
#[error(transparent)]
ProtoBufEncode(#[from] prost::EncodeError),

/// Error generated by the protobuf library when decoding.
#[error(transparent)]
ProtoBufDecode(#[from] prost::DecodeError),

/// Error generated by the protobuf library when converting enums.
#[error(transparent)]
ProtoEnum(#[from] prost::UnknownEnumValue),

/// Errors generated by the IO module.
#[error(transparent)]
Io(#[from] std::io::Error),
Expand Down
16 changes: 0 additions & 16 deletions crates/ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
mod error;

mod bindings;
#[cfg(feature = "client")]
mod client;
#[cfg(feature = "server")]
Expand Down Expand Up @@ -59,21 +58,6 @@ impl Default for ServiceAppInfo {
}
}

/// Encode to protobuf.
pub(crate) fn encode_proto<T: prost::Message>(value: &T) -> Result<Vec<u8>> {
let mut buf = Vec::new();
buf.reserve(value.encoded_len());
value.encode(&mut buf)?;
Ok(buf)
}

/// Decode from protobuf.
pub(crate) fn decode_proto<T: prost::Message + Default>(
buffer: &[u8],
) -> Result<T> {
Ok(T::decode(buffer)?)
}

#[doc(hidden)]
pub fn remove_socket_file(socket_name: &str) {
if cfg!(target_os = "macos") {
Expand Down
24 changes: 0 additions & 24 deletions crates/ipc/src/local_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,30 +257,6 @@ impl LocalServer {
}
}

/*
pub async fn handle(&self, req: LocalRequest) -> LocalResponse {
let res = match req.try_into() {
Ok(req) => self.call(req).await,
Err(e) => Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(e.to_string().as_bytes().to_vec())
.unwrap(),
};
res.into()
}
*/

pub(crate) async fn call(
&self,
req: Request<Incoming>,
) -> hyper::Result<Response<Body>> {
let router = self.router.clone();
Ok(match Self::route(router, req).await {
Ok(result) => result,
Err(e) => internal_server_error(e).unwrap(),
})
}

async fn route(
router: Arc<Router>,
req: Request<Incoming>,
Expand Down
25 changes: 0 additions & 25 deletions crates/ipc/src/protobuf/common.proto

This file was deleted.

0 comments on commit e3a2479

Please sign in to comment.