diff --git a/example/Cargo.toml b/example/Cargo.toml index 47094e6b..64116403 100644 --- a/example/Cargo.toml +++ b/example/Cargo.toml @@ -51,3 +51,7 @@ path = "./async-stream-client.rs" [build-dependencies] ttrpc-codegen = { path = "../ttrpc-codegen"} + +[patch.crates-io] +ttrpc-compiler = { path = "../compiler"} + diff --git a/example/async-client.rs b/example/async-client.rs index 4c4b7e9f..c298cbd2 100644 --- a/example/async-client.rs +++ b/example/async-client.rs @@ -6,7 +6,7 @@ mod protocols; mod utils; #[cfg(unix)] -use protocols::r#async::{agent, agent_ttrpc, health, health_ttrpc}; +use protocols::asynchronous::{agent, agent_ttrpc, health, health_ttrpc}; use ttrpc::context::{self, Context}; #[cfg(unix)] use ttrpc::r#async::Client; diff --git a/example/async-server.rs b/example/async-server.rs index 1ee2fb79..074d8274 100644 --- a/example/async-server.rs +++ b/example/async-server.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use log::LevelFilter; #[cfg(unix)] -use protocols::r#async::{agent, agent_ttrpc, health, health_ttrpc, types}; +use protocols::asynchronous::{agent, agent_ttrpc, health, health_ttrpc, types}; #[cfg(unix)] use ttrpc::asynchronous::Server; use ttrpc::error::{Error, Result}; @@ -97,13 +97,8 @@ fn main() { async fn main() { simple_logging::log_to_stderr(LevelFilter::Trace); - let h = Box::new(HealthService {}) as Box; - let h = Arc::new(h); - let hservice = health_ttrpc::create_health(h); - - let a = Box::new(AgentService {}) as Box; - let a = Arc::new(a); - let aservice = agent_ttrpc::create_agent_service(a); + let hservice = health_ttrpc::create_health(Arc::new(HealthService {})); + let aservice = agent_ttrpc::create_agent_service(Arc::new(AgentService {})); utils::remove_if_sock_exist(utils::SOCK_ADDR).unwrap(); diff --git a/example/async-stream-client.rs b/example/async-stream-client.rs index 6186de39..04f8c7b6 100644 --- a/example/async-stream-client.rs +++ b/example/async-stream-client.rs @@ -6,7 +6,7 @@ mod protocols; mod utils; #[cfg(unix)] -use protocols::r#async::{empty, streaming, streaming_ttrpc}; +use protocols::asynchronous::{empty, streaming, streaming_ttrpc}; use ttrpc::context::{self, Context}; #[cfg(unix)] use ttrpc::r#async::Client; diff --git a/example/async-stream-server.rs b/example/async-stream-server.rs index 250a5ff5..4dcba884 100644 --- a/example/async-stream-server.rs +++ b/example/async-stream-server.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use log::{info, LevelFilter}; #[cfg(unix)] -use protocols::r#async::{empty, streaming, streaming_ttrpc}; +use protocols::asynchronous::{empty, streaming, streaming_ttrpc}; #[cfg(unix)] use ttrpc::{asynchronous::Server, Error}; @@ -163,11 +163,7 @@ fn main() { #[tokio::main(flavor = "current_thread")] async fn main() { simple_logging::log_to_stderr(LevelFilter::Info); - - let s = Box::new(StreamingService {}) as Box; - let s = Arc::new(s); - let service = streaming_ttrpc::create_streaming(s); - + let service = streaming_ttrpc::create_streaming(Arc::new(StreamingService {})); utils::remove_if_sock_exist(utils::SOCK_ADDR).unwrap(); let mut server = Server::new() diff --git a/example/protocols/mod.rs b/example/protocols/mod.rs index d3d3a275..9ed5a35a 100644 --- a/example/protocols/mod.rs +++ b/example/protocols/mod.rs @@ -5,5 +5,4 @@ #[cfg(unix)] pub mod asynchronous; #[cfg(unix)] -pub use asynchronous as r#async; pub mod sync; diff --git a/example/server.rs b/example/server.rs index c15bf337..54d33f21 100644 --- a/example/server.rs +++ b/example/server.rs @@ -81,14 +81,8 @@ impl agent_ttrpc::AgentService for AgentService { fn main() { simple_logging::log_to_stderr(LevelFilter::Trace); - - let h = Box::new(HealthService {}) as Box; - let h = Arc::new(h); - let hservice = health_ttrpc::create_health(h); - - let a = Box::new(AgentService {}) as Box; - let a = Arc::new(a); - let aservice = agent_ttrpc::create_agent_service(a); + let hservice = health_ttrpc::create_health(Arc::new(HealthService {})); + let aservice = agent_ttrpc::create_agent_service(Arc::new(AgentService {})); utils::remove_if_sock_exist(utils::SOCK_ADDR).unwrap(); let mut server = Server::new()