Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of unused transport feature. #1112

Merged
merged 9 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is supposed to be ignored? We want the test to run and it should generate the exact code that was committed? Does it not work like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo test --ignored run tests which are marked as #[ignored].
So scheme is next:

  1. running test --all --all-features in root directory with all packages causes to transport feature on for tonic-builds, which lead to overriding dev-dependencies in tonic-health, which lead to rerun bootstrap.rs with transport feature, which lead to generating transport code;
  2. so we ignore that bootstrap in test --all, but run this test separately;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're saying, I think the better approach here is to add a build_transport feature that when transport is enabled for build can disable it. So in the bootstrap test we can just tell it even if transport is enabled don't generate it. Here is the PR #1130 so once that is merged you can just add the build_transport(false) setting to tonic-health's bootstrap.rs and then remove the transport feature. Or if it works you can make it so that when health's transport feature is enabled it sets that to true etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I finally got the PR merged after 3 days of trying to fix a CI bug with it! So if you update this PR with that then we can move forward. We should back out the CI changes etc the test should pass now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I finally got the PR merged after 3 days of trying to fix a CI bug with it! So if you update this PR with that then we can move forward. We should back out the CI changes etc the test should pass now.

Okey, now it have:

Run cargo test --all --all-features
    Updating git repository `[https://github.com/tokio-rs/prost/`](https://github.com/tokio-rs/prost/%60)
error: failed to load source for dependency `prost-build`

Caused by:
  Unable to update https://github.com/tokio-rs/prost/?branch=lucio/format


interop:
name: Interop Tests
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tonic-health/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ version = "0.7.1"

[features]
default = ["transport"]
transport = ["tonic/transport"]
transport = []

[dependencies]
async-stream = "0.3"
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"] }
6 changes: 5 additions & 1 deletion tonic-health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
71 changes: 30 additions & 41 deletions tonic-health/src/generated/grpc.health.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ pub mod health_client {
pub struct HealthClient<T> {
inner: tonic::client::Grpc<T>,
}
impl HealthClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> HealthClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
Expand Down Expand Up @@ -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<super::HealthCheckRequest>,
Expand All @@ -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<super::HealthCheckRequest>,
Expand Down Expand Up @@ -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<super::HealthCheckRequest>,
Expand All @@ -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<super::HealthCheckRequest>,
Expand Down
2 changes: 1 addition & 1 deletion tonic-health/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tonic-health/tests/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{path::PathBuf, process::Command};

#[ignore]
#[test]
fn bootstrap() {
let iface_files = &["proto/health.proto"];
Expand Down
7 changes: 4 additions & 3 deletions tonic-reflection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ 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"]}
BratSinot marked this conversation as resolved.
Show resolved Hide resolved
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"