From 0a1cb8c6da60c4e61ed565179225dff20c228eea Mon Sep 17 00:00:00 2001 From: Sunli Date: Sun, 19 Nov 2023 14:43:37 +0800 Subject: [PATCH] update examples --- examples/Cargo.toml | 2 +- examples/poem/tonic/Cargo.toml | 7 ++++--- examples/poem/tonic/src/main.rs | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 662163f802..c25fd954e0 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -21,4 +21,4 @@ serde = { version = "1.0.140", features = ["derive"] } mime = "0.3.16" futures-util = "0.3.21" tokio-stream = "0.1.8" -prost = "0.11.0" +prost = "0.12.0" diff --git a/examples/poem/tonic/Cargo.toml b/examples/poem/tonic/Cargo.toml index 5fcf39b00c..42779231db 100644 --- a/examples/poem/tonic/Cargo.toml +++ b/examples/poem/tonic/Cargo.toml @@ -7,12 +7,13 @@ publish.workspace = true [dependencies] poem = { workspace = true, features = ["tower-compat"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -prost = "0.9.0" -tonic = "0.6.2" +prost = "0.12.0" +tonic = "0.10.2" tracing-subscriber.workspace = true +tower = { version = "0.4.8", features = ["buffer"] } [build-dependencies] -tonic-build = "0.5.2" +tonic-build = "0.10.2" [[bin]] name = "example-tonic-client" diff --git a/examples/poem/tonic/src/main.rs b/examples/poem/tonic/src/main.rs index 08195bad33..5893a32246 100644 --- a/examples/poem/tonic/src/main.rs +++ b/examples/poem/tonic/src/main.rs @@ -4,6 +4,7 @@ use hello_world::{ }; use poem::{endpoint::TowerCompatExt, listener::TcpListener, Route, Server}; use tonic::{Request, Response, Status}; +use tower::buffer::Buffer; pub mod hello_world { tonic::include_proto!("helloworld"); @@ -31,13 +32,13 @@ async fn main() -> Result<(), std::io::Error> { } tracing_subscriber::fmt::init(); - let app = Route::new().nest_no_strip( - "/", + let service = Buffer::new( tonic::transport::Server::builder() .add_service(GreeterServer::new(MyGreeter)) - .into_service() - .compat(), + .into_service(), + 1024, ); + let app = Route::new().nest_no_strip("/", service.compat()); Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app)