From a9804407736e9e8a4badf140deb7884aee517f70 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 14 Oct 2022 17:06:35 +0200 Subject: [PATCH 1/8] Get rid of unused transport feature. --- tonic-health/Cargo.toml | 4 ++-- tonic-reflection/Cargo.toml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tonic-health/Cargo.toml b/tonic-health/Cargo.toml index b1dcb44b8..8098dffab 100644 --- a/tonic-health/Cargo.toml +++ b/tonic-health/Cargo.toml @@ -24,8 +24,8 @@ bytes = "1.0" prost = "0.11" tokio = {version = "1.0", features = ["sync"]} tokio-stream = "0.1" -tonic = {version = "0.8", path = "../tonic", features = ["codegen", "prost"]} +tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["codegen", "prost"] } [dev-dependencies] tokio = {version = "1.0", features = ["rt-multi-thread", "macros"]} -tonic-build = {version = "0.8", path = "../tonic-build", features = ["prost"]} +tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost"] } diff --git a/tonic-reflection/Cargo.toml b/tonic-reflection/Cargo.toml index ad7987b99..314707cab 100644 --- a/tonic-reflection/Cargo.toml +++ b/tonic-reflection/Cargo.toml @@ -23,11 +23,12 @@ prost = "0.11" prost-types = "0.11" tokio = {version = "1.0", features = ["sync"]} tokio-stream = {version = "0.1", features = ["net"]} -tonic = {version = "0.8", path = "../tonic", features = ["codegen", "prost"]} +tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["codegen", "prost"] } [build-dependencies] -tonic-build = {version = "0.8", path = "../tonic-build", features = ["transport", "prost"]} +tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost"] } [dev-dependencies] +tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["transport"] } futures = "0.3" futures-util = "0.3" From fc7e4587648ed557446dfdc2142c6300984f77d4 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Wed, 19 Oct 2022 13:24:13 +0200 Subject: [PATCH 2/8] bootstrap --- tonic-health/src/generated/grpc.health.v1.rs | 71 +++++++++----------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/tonic-health/src/generated/grpc.health.v1.rs b/tonic-health/src/generated/grpc.health.v1.rs index c5bd71f6a..9457d3ee8 100644 --- a/tonic-health/src/generated/grpc.health.v1.rs +++ b/tonic-health/src/generated/grpc.health.v1.rs @@ -43,17 +43,6 @@ pub mod health_client { pub struct HealthClient { inner: tonic::client::Grpc, } - impl HealthClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: std::convert::TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } impl HealthClient where T: tonic::client::GrpcService, @@ -103,8 +92,8 @@ pub mod health_client { self.inner = self.inner.accept_compressed(encoding); self } - ///If the requested service is unknown, the call will fail with status - ///NOT_FOUND. + /// If the requested service is unknown, the call will fail with status + /// NOT_FOUND. pub async fn check( &mut self, request: impl tonic::IntoRequest, @@ -124,21 +113,21 @@ pub mod health_client { ); self.inner.unary(request.into_request(), path, codec).await } - ///Performs a watch for the serving status of the requested service. - ///The server will immediately send back a message indicating the current - ///serving status. It will then subsequently send a new message whenever - ///the service's serving status changes. + /// Performs a watch for the serving status of the requested service. + /// The server will immediately send back a message indicating the current + /// serving status. It will then subsequently send a new message whenever + /// the service's serving status changes. /// - ///If the requested service is unknown when the call is received, the - ///server will send a message setting the serving status to - ///SERVICE_UNKNOWN but will *not* terminate the call. If at some - ///future point, the serving status of the service becomes known, the - ///server will send a new message with the service's serving status. + /// If the requested service is unknown when the call is received, the + /// server will send a message setting the serving status to + /// SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// future point, the serving status of the service becomes known, the + /// server will send a new message with the service's serving status. /// - ///If the call terminates with status UNIMPLEMENTED, then clients - ///should assume this method is not supported and should not retry the - ///call. If the call terminates with any other status (including OK), - ///clients should retry the call with appropriate exponential backoff. + /// If the call terminates with status UNIMPLEMENTED, then clients + /// should assume this method is not supported and should not retry the + /// call. If the call terminates with any other status (including OK), + /// clients should retry the call with appropriate exponential backoff. pub async fn watch( &mut self, request: impl tonic::IntoRequest, @@ -170,8 +159,8 @@ pub mod health_server { ///Generated trait containing gRPC methods that should be implemented for use with HealthServer. #[async_trait] pub trait Health: Send + Sync + 'static { - ///If the requested service is unknown, the call will fail with status - ///NOT_FOUND. + /// If the requested service is unknown, the call will fail with status + /// NOT_FOUND. async fn check( &self, request: tonic::Request, @@ -182,21 +171,21 @@ pub mod health_server { > + Send + 'static; - ///Performs a watch for the serving status of the requested service. - ///The server will immediately send back a message indicating the current - ///serving status. It will then subsequently send a new message whenever - ///the service's serving status changes. + /// Performs a watch for the serving status of the requested service. + /// The server will immediately send back a message indicating the current + /// serving status. It will then subsequently send a new message whenever + /// the service's serving status changes. /// - ///If the requested service is unknown when the call is received, the - ///server will send a message setting the serving status to - ///SERVICE_UNKNOWN but will *not* terminate the call. If at some - ///future point, the serving status of the service becomes known, the - ///server will send a new message with the service's serving status. + /// If the requested service is unknown when the call is received, the + /// server will send a message setting the serving status to + /// SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// future point, the serving status of the service becomes known, the + /// server will send a new message with the service's serving status. /// - ///If the call terminates with status UNIMPLEMENTED, then clients - ///should assume this method is not supported and should not retry the - ///call. If the call terminates with any other status (including OK), - ///clients should retry the call with appropriate exponential backoff. + /// If the call terminates with status UNIMPLEMENTED, then clients + /// should assume this method is not supported and should not retry the + /// call. If the call terminates with any other status (including OK), + /// clients should retry the call with appropriate exponential backoff. async fn watch( &self, request: tonic::Request, From bc01c75c387b545933ab466f5cdb6e2d4c938f15 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Thu, 27 Oct 2022 13:57:10 +0200 Subject: [PATCH 3/8] Remove enabling tonic/transport feature. --- tonic-health/Cargo.toml | 2 +- tonic-health/README.md | 6 +++++- tonic-health/src/server.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tonic-health/Cargo.toml b/tonic-health/Cargo.toml index 8098dffab..049c29676 100644 --- a/tonic-health/Cargo.toml +++ b/tonic-health/Cargo.toml @@ -16,7 +16,7 @@ version = "0.7.1" [features] default = ["transport"] -transport = ["tonic/transport"] +transport = [] [dependencies] async-stream = "0.3" diff --git a/tonic-health/README.md b/tonic-health/README.md index 7e8112938..b386668d4 100644 --- a/tonic-health/README.md +++ b/tonic-health/README.md @@ -7,4 +7,8 @@ Please follow the example in the [main repo](https://github.com/hyperium/tonic/t ## Features - transport: Provides the ability to set the service by using the type system and the -`NamedService` trait. +`NamedService` trait. You can use it like that: +```rust + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + let client = HealthClient::new(conn); +``` diff --git a/tonic-health/src/server.rs b/tonic-health/src/server.rs index 53e4ef9e2..10ec38a0e 100644 --- a/tonic-health/src/server.rs +++ b/tonic-health/src/server.rs @@ -9,7 +9,7 @@ use std::sync::Arc; use tokio::sync::{watch, RwLock}; use tokio_stream::Stream; #[cfg(feature = "transport")] -use tonic::transport::NamedService; +use tonic::server::NamedService; use tonic::{Request, Response, Status}; /// Creates a `HealthReporter` and a linked `HealthServer` pair. Together, From 6fe9648e18a6cc42f65922bea698922c0aa67b44 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 28 Oct 2022 10:47:04 +0200 Subject: [PATCH 4/8] Fix missing tokio::spawn error. --- tonic-reflection/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tonic-reflection/Cargo.toml b/tonic-reflection/Cargo.toml index 314707cab..66da8889f 100644 --- a/tonic-reflection/Cargo.toml +++ b/tonic-reflection/Cargo.toml @@ -21,7 +21,7 @@ version = "0.5.0" bytes = "1.0" prost = "0.11" prost-types = "0.11" -tokio = {version = "1.0", features = ["sync"]} +tokio = {version = "1.0", features = ["sync", "rt"]} tokio-stream = {version = "0.1", features = ["net"]} tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["codegen", "prost"] } From bb7b8d7661f6f45b037b60b2297109201337b6c3 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 28 Oct 2022 13:05:05 +0200 Subject: [PATCH 5/8] tonic-health bootstrap mark as ignored and run separately. --- .github/workflows/CI.yml | 8 +++++--- tonic-health/tests/bootstrap.rs | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ce2a9ce59..b54b9c98d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,7 +29,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Check fmt run: cargo fmt -- --check @@ -66,11 +66,13 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - uses: actions/checkout@master - name: Run tests run: cargo test --all --all-features + - name: Run ignored tonic-health bootstrap test + run: cargo test --all-features --package tonic-health --test bootstrap bootstrap -- --ignored --exact interop: name: Interop Tests @@ -93,7 +95,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Run interop tests run: ./interop/test.sh diff --git a/tonic-health/tests/bootstrap.rs b/tonic-health/tests/bootstrap.rs index bbf4f9cfa..a0a45b7a5 100644 --- a/tonic-health/tests/bootstrap.rs +++ b/tonic-health/tests/bootstrap.rs @@ -1,5 +1,6 @@ use std::{path::PathBuf, process::Command}; +#[ignore] #[test] fn bootstrap() { let iface_files = &["proto/health.proto"]; From 03d267b5d656a86a12a6d8e569329e06ef6958eb Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 4 Nov 2022 18:09:11 +0100 Subject: [PATCH 6/8] Revert "tonic-health bootstrap mark as ignored and run separately." This reverts commit bb7b8d7661f6f45b037b60b2297109201337b6c3. --- .github/workflows/CI.yml | 8 +++----- tonic-health/tests/bootstrap.rs | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b54b9c98d..ce2a9ce59 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,7 +29,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Check fmt run: cargo fmt -- --check @@ -66,13 +66,11 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - uses: actions/checkout@master - name: Run tests run: cargo test --all --all-features - - name: Run ignored tonic-health bootstrap test - run: cargo test --all-features --package tonic-health --test bootstrap bootstrap -- --ignored --exact interop: name: Interop Tests @@ -95,7 +93,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Run interop tests run: ./interop/test.sh diff --git a/tonic-health/tests/bootstrap.rs b/tonic-health/tests/bootstrap.rs index a0a45b7a5..bbf4f9cfa 100644 --- a/tonic-health/tests/bootstrap.rs +++ b/tonic-health/tests/bootstrap.rs @@ -1,6 +1,5 @@ use std::{path::PathBuf, process::Command}; -#[ignore] #[test] fn bootstrap() { let iface_files = &["proto/health.proto"]; From 966d6515a65e34f7cdfa472bc39617cdf1bb2aa8 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 4 Nov 2022 20:05:13 +0100 Subject: [PATCH 7/8] Remove extra spaces in CI.yml. --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ce2a9ce59..1007ebfc3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,7 +29,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Check fmt run: cargo fmt -- --check @@ -66,7 +66,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - uses: actions/checkout@master - name: Run tests @@ -93,7 +93,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v1 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v1 - name: Run interop tests run: ./interop/test.sh From 2aed34e6eb8abbde91bf098ff60741a6ebed6a67 Mon Sep 17 00:00:00 2001 From: Aleksandr Sinotov Date: Fri, 4 Nov 2022 20:35:20 +0100 Subject: [PATCH 8/8] build_transport(false) --- tonic-health/tests/bootstrap.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tonic-health/tests/bootstrap.rs b/tonic-health/tests/bootstrap.rs index bbf4f9cfa..bb3241aa0 100644 --- a/tonic-health/tests/bootstrap.rs +++ b/tonic-health/tests/bootstrap.rs @@ -12,6 +12,7 @@ fn bootstrap() { tonic_build::configure() .build_client(true) .build_server(true) + .build_transport(false) .out_dir(format!("{}", out_dir.display())) .compile(iface_files, dirs) .unwrap();