diff --git a/examples/Cargo.toml b/examples/Cargo.toml index d6cc1b5c6..b1be167ed 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -98,16 +98,6 @@ name = "tower-client" path = "src/tower/client.rs" required-features = ["tower"] -[[bin]] -name = "timeout-server" -path = "src/timeout/server.rs" -required-features = ["timeout"] - -[[bin]] -name = "timeout-client" -path = "src/timeout/client.rs" -required-features = ["timeout"] - [[bin]] name = "multiplex-server" path = "src/multiplex/server.rs" @@ -278,13 +268,12 @@ compression = ["tonic/gzip"] tls = ["tonic/tls"] tls-rustls = ["dep:http", "dep:hyper", "dep:hyper-util", "dep:hyper-rustls", "dep:tower", "tower-http/util", "tower-http/add-extension", "dep:rustls-pemfile", "dep:tokio-rustls", "dep:pin-project", "dep:http-body-util"] dynamic-load-balance = ["dep:tower"] -timeout = ["tokio/time", "dep:tower", "tower?/timeout"] tls-client-auth = ["tonic/tls"] types = ["dep:tonic-types"] h2c = ["dep:hyper", "dep:tower", "dep:http", "dep:hyper-util"] cancellation = ["dep:tokio-util"] -full = ["gcp", "routeguide", "reflection", "autoreload", "health", "grpc-web", "tracing", "uds", "streaming", "mock", "tower", "json-codec", "compression", "tls", "tls-rustls", "dynamic-load-balance", "timeout", "tls-client-auth", "types", "cancellation", "h2c"] +full = ["gcp", "routeguide", "reflection", "autoreload", "health", "grpc-web", "tracing", "uds", "streaming", "mock", "tower", "json-codec", "compression", "tls", "tls-rustls", "dynamic-load-balance", "tls-client-auth", "types", "cancellation", "h2c"] default = ["full"] [dependencies] diff --git a/examples/src/timeout/client.rs b/examples/src/timeout/client.rs deleted file mode 100644 index e7e288ae7..000000000 --- a/examples/src/timeout/client.rs +++ /dev/null @@ -1,28 +0,0 @@ -use hello_world::greeter_client::GreeterClient; -use hello_world::HelloRequest; -use std::time::Duration; -use tower::timeout::Timeout; - -use tonic::transport::Channel; - -pub mod hello_world { - tonic::include_proto!("helloworld"); -} - -#[tokio::main] -async fn main() -> Result<(), Box> { - let channel = Channel::from_static("http://[::1]:50051").connect().await?; - let timeout_channel = Timeout::new(channel, Duration::from_millis(1000)); - - let mut client = GreeterClient::new(timeout_channel); - - let request = tonic::Request::new(HelloRequest { - name: "Tonic".into(), - }); - - let response = client.say_hello(request).await?; - - println!("RESPONSE={:?}", response); - - Ok(()) -} diff --git a/examples/src/timeout/server.rs b/examples/src/timeout/server.rs deleted file mode 100644 index 2d5b1fa2e..000000000 --- a/examples/src/timeout/server.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::time::Duration; -use tokio::time::sleep; -use tonic::{transport::Server, Request, Response, Status}; - -use hello_world::greeter_server::{Greeter, GreeterServer}; -use hello_world::{HelloReply, HelloRequest}; - -pub mod hello_world { - tonic::include_proto!("helloworld"); -} - -#[derive(Default)] -pub struct MyGreeter {} - -#[tonic::async_trait] -impl Greeter for MyGreeter { - async fn say_hello( - &self, - request: Request, - ) -> Result, Status> { - println!("Got a request from {:?}", request.remote_addr()); - - sleep(Duration::from_millis(5000)).await; - - let reply = hello_world::HelloReply { - message: format!("Hello {}!", request.into_inner().name), - }; - Ok(Response::new(reply)) - } -} - -#[tokio::main] -async fn main() -> Result<(), Box> { - let addr = "[::1]:50051".parse().unwrap(); - let greeter = MyGreeter::default(); - - println!("GreeterServer listening on {}", addr); - - Server::builder() - .add_service(GreeterServer::new(greeter)) - .serve(addr) - .await?; - - Ok(()) -}