Skip to content

Commit

Permalink
example: update to match new ttrpc-compiler
Browse files Browse the repository at this point in the history
update for commit 1f2a26

Signed-off-by: Tim Zhang <[email protected]>
  • Loading branch information
Tim-Zhang committed Sep 25, 2024
1 parent 1f2a266 commit 0aabe06
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 25 deletions.
4 changes: 4 additions & 0 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ path = "./async-stream-client.rs"

[build-dependencies]
ttrpc-codegen = { path = "../ttrpc-codegen"}

[patch.crates-io]
ttrpc-compiler = { path = "../compiler"}

2 changes: 1 addition & 1 deletion example/async-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions example/async-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -97,13 +97,8 @@ fn main() {
async fn main() {
simple_logging::log_to_stderr(LevelFilter::Trace);

let h = Box::new(HealthService {}) as Box<dyn health_ttrpc::Health + Send + Sync>;
let h = Arc::new(h);
let hservice = health_ttrpc::create_health(h);

let a = Box::new(AgentService {}) as Box<dyn agent_ttrpc::AgentService + Send + Sync>;
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();

Expand Down
2 changes: 1 addition & 1 deletion example/async-stream-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions example/async-stream-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<dyn streaming_ttrpc::Streaming + Send + Sync>;
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()
Expand Down
1 change: 0 additions & 1 deletion example/protocols/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
#[cfg(unix)]
pub mod asynchronous;
#[cfg(unix)]
pub use asynchronous as r#async;
pub mod sync;
10 changes: 2 additions & 8 deletions example/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn health_ttrpc::Health + Send + Sync>;
let h = Arc::new(h);
let hservice = health_ttrpc::create_health(h);

let a = Box::new(AgentService {}) as Box<dyn agent_ttrpc::AgentService + Send + Sync>;
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()
Expand Down

0 comments on commit 0aabe06

Please sign in to comment.