From 9722b054f1c048e6c85c4908cf863275da351e70 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 23 Aug 2024 15:43:05 +0200 Subject: [PATCH] reflection: deprecate non-specific build() method --- tonic-reflection/src/server/mod.rs | 10 +++++++++- tonic-reflection/tests/server.rs | 2 +- tonic-reflection/tests/versions.rs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tonic-reflection/src/server/mod.rs b/tonic-reflection/src/server/mod.rs index c317685e5..9d7ce2d5e 100644 --- a/tonic-reflection/src/server/mod.rs +++ b/tonic-reflection/src/server/mod.rs @@ -73,7 +73,15 @@ impl<'b> Builder<'b> { } /// Build a v1 gRPC Reflection Service to be served via Tonic. - pub fn build(mut self) -> Result, Error> { + #[deprecated(since = "0.12.2", note = "use `build_v1()` instead")] + pub fn build(self) -> Result, Error> { + self.build_v1() + } + + /// Build a v1 gRPC Reflection Service to be served via Tonic. + pub fn build_v1( + mut self, + ) -> Result, Error> { if self.include_reflection_service { self = self.register_encoded_file_descriptor_set(crate::pb::v1::FILE_DESCRIPTOR_SET); } diff --git a/tonic-reflection/tests/server.rs b/tonic-reflection/tests/server.rs index facb75034..48d3a5393 100644 --- a/tonic-reflection/tests/server.rs +++ b/tonic-reflection/tests/server.rs @@ -100,7 +100,7 @@ async fn make_test_reflection_request(request: ServerReflectionRequest) -> Messa let jh = tokio::spawn(async move { let service = Builder::configure() .register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET) - .build() + .build_v1() .unwrap(); Server::builder() diff --git a/tonic-reflection/tests/versions.rs b/tonic-reflection/tests/versions.rs index 7674d7781..e55fa8a16 100644 --- a/tonic-reflection/tests/versions.rs +++ b/tonic-reflection/tests/versions.rs @@ -64,7 +64,7 @@ async fn make_v1_request( let listener = tokio::net::TcpListener::bind(addr).await.expect("bind"); let local_addr = format!("http://{}", listener.local_addr().expect("local address")); let jh = tokio::spawn(async move { - let service = Builder::configure().build().unwrap(); + let service = Builder::configure().build_v1().unwrap(); Server::builder() .add_service(service)