Skip to content

Commit d2542dc

Browse files
authoredJan 10, 2023
feat: Rename api related to protobuf (#1224)
1 parent 0d35d7f commit d2542dc

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed
 

‎tonic-health/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@
2424
use std::fmt::{Display, Formatter};
2525

2626
/// Generated protobuf types from the `grpc.health.v1` package.
27-
pub mod proto {
27+
pub mod pb {
2828
#![allow(unreachable_pub)]
2929
#![allow(missing_docs)]
3030
include!("generated/grpc.health.v1.rs");
3131

32-
pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &[u8] =
33-
include_bytes!("generated/grpc_health_v1.bin");
32+
/// Byte encoded FILE_DESCRIPTOR_SET.
33+
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("generated/grpc_health_v1.bin");
3434

3535
#[cfg(test)]
3636
mod tests {
37-
use super::GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET;
37+
use super::FILE_DESCRIPTOR_SET;
3838
use prost::Message as _;
3939

4040
#[test]
4141
fn file_descriptor_set_is_valid() {
42-
prost_types::FileDescriptorSet::decode(GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET).unwrap();
42+
prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap();
4343
}
4444
}
4545
}
@@ -67,12 +67,12 @@ impl Display for ServingStatus {
6767
}
6868
}
6969

70-
impl From<ServingStatus> for proto::health_check_response::ServingStatus {
70+
impl From<ServingStatus> for pb::health_check_response::ServingStatus {
7171
fn from(s: ServingStatus) -> Self {
7272
match s {
73-
ServingStatus::Unknown => proto::health_check_response::ServingStatus::Unknown,
74-
ServingStatus::Serving => proto::health_check_response::ServingStatus::Serving,
75-
ServingStatus::NotServing => proto::health_check_response::ServingStatus::NotServing,
73+
ServingStatus::Unknown => pb::health_check_response::ServingStatus::Unknown,
74+
ServingStatus::Serving => pb::health_check_response::ServingStatus::Serving,
75+
ServingStatus::NotServing => pb::health_check_response::ServingStatus::NotServing,
7676
}
7777
}
7878
}

‎tonic-health/src/server.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Contains all healthcheck based server utilities.
22
3-
use crate::proto::health_server::{Health, HealthServer};
4-
use crate::proto::{HealthCheckRequest, HealthCheckResponse};
3+
use crate::pb::health_server::{Health, HealthServer};
4+
use crate::pb::{HealthCheckRequest, HealthCheckResponse};
55
use crate::ServingStatus;
66
use std::collections::HashMap;
77
use std::pin::Pin;
@@ -132,7 +132,7 @@ impl Health for HealthService {
132132
match status {
133133
None => Err(Status::not_found("service not registered")),
134134
Some(status) => Ok(Response::new(HealthCheckResponse {
135-
status: crate::proto::health_check_response::ServingStatus::from(status) as i32,
135+
status: crate::pb::health_check_response::ServingStatus::from(status) as i32,
136136
})),
137137
}
138138
}
@@ -152,11 +152,11 @@ impl Health for HealthService {
152152

153153
let output = async_stream::try_stream! {
154154
// yield the current value
155-
let status = crate::proto::health_check_response::ServingStatus::from(*status_rx.borrow()) as i32;
155+
let status = crate::pb::health_check_response::ServingStatus::from(*status_rx.borrow()) as i32;
156156
yield HealthCheckResponse { status };
157157

158158
while let Ok(_) = status_rx.changed().await {
159-
let status = crate::proto::health_check_response::ServingStatus::from(*status_rx.borrow()) as i32;
159+
let status = crate::pb::health_check_response::ServingStatus::from(*status_rx.borrow()) as i32;
160160
yield HealthCheckResponse { status };
161161
}
162162
};
@@ -167,16 +167,16 @@ impl Health for HealthService {
167167

168168
#[cfg(test)]
169169
mod tests {
170-
use crate::proto::health_server::Health;
171-
use crate::proto::HealthCheckRequest;
170+
use crate::pb::health_server::Health;
171+
use crate::pb::HealthCheckRequest;
172172
use crate::server::{HealthReporter, HealthService};
173173
use crate::ServingStatus;
174174
use tokio::sync::watch;
175175
use tokio_stream::StreamExt;
176176
use tonic::{Code, Request, Status};
177177

178178
fn assert_serving_status(wire: i32, expected: ServingStatus) {
179-
let expected = crate::proto::health_check_response::ServingStatus::from(expected) as i32;
179+
let expected = crate::pb::health_check_response::ServingStatus::from(expected) as i32;
180180
assert_eq!(wire, expected);
181181
}
182182

‎tonic-reflection/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
#![cfg_attr(docsrs, feature(doc_cfg))]
1717

1818
/// Generated protobuf types from the `grpc.reflection.v1alpha` package.
19-
pub mod proto {
19+
pub mod pb {
2020
#![allow(unreachable_pub)]
2121
#![allow(missing_docs)]
2222
#![allow(rustdoc::invalid_html_tags)]
2323
include!("generated/grpc.reflection.v1alpha.rs");
2424

25+
/// Byte encoded FILE_DESCRIPTOR_SET.
2526
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("generated/reflection_v1alpha1.bin");
2627

2728
#[cfg(test)]

‎tonic-reflection/src/server.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::proto::server_reflection_request::MessageRequest;
2-
use crate::proto::server_reflection_response::MessageResponse;
3-
pub use crate::proto::server_reflection_server::{ServerReflection, ServerReflectionServer};
4-
use crate::proto::{
1+
use crate::pb::server_reflection_request::MessageRequest;
2+
use crate::pb::server_reflection_response::MessageResponse;
3+
pub use crate::pb::server_reflection_server::{ServerReflection, ServerReflectionServer};
4+
use crate::pb::{
55
ExtensionNumberResponse, FileDescriptorResponse, ListServiceResponse, ServerReflectionRequest,
66
ServerReflectionResponse, ServiceResponse,
77
};
@@ -109,7 +109,7 @@ impl<'b> Builder<'b> {
109109
/// Build a gRPC Reflection Service to be served via Tonic.
110110
pub fn build(mut self) -> Result<ServerReflectionServer<impl ServerReflection>, Error> {
111111
if self.include_reflection_service {
112-
self = self.register_encoded_file_descriptor_set(crate::proto::FILE_DESCRIPTOR_SET);
112+
self = self.register_encoded_file_descriptor_set(crate::pb::FILE_DESCRIPTOR_SET);
113113
}
114114

115115
for encoded in &self.encoded_file_descriptor_sets {

‎tonic-reflection/tests/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tokio::sync::oneshot;
66
use tokio_stream::{wrappers::TcpListenerStream, StreamExt};
77
use tonic::{transport::Server, Request};
88
use tonic_reflection::{
9-
proto::{
9+
pb::{
1010
server_reflection_client::ServerReflectionClient,
1111
server_reflection_request::MessageRequest, server_reflection_response::MessageResponse,
1212
ServerReflectionRequest, ServiceResponse, FILE_DESCRIPTOR_SET,

0 commit comments

Comments
 (0)
Please sign in to comment.