From ab5b586b4af1b48221ca74c4b4561ea28c51bd58 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Mon, 15 Mar 2021 21:00:40 +0800 Subject: [PATCH] use code generated by old compiler Signed-off-by: Jay Lee --- health/Cargo.toml | 8 +- health/build.rs | 14 - health/proto/grpc/health/v1/health.proto | 63 --- health/src/lib.rs | 2 +- health/src/proto.rs | 28 +- health/src/proto/grpc.health.v1.rs | 48 +++ health/src/proto/health.rs | 514 +++++++++++++++++++++++ health/src/proto/health_grpc.rs | 140 ++++++ 8 files changed, 713 insertions(+), 104 deletions(-) delete mode 100644 health/build.rs delete mode 100644 health/proto/grpc/health/v1/health.proto create mode 100644 health/src/proto/grpc.health.v1.rs create mode 100644 health/src/proto/health.rs create mode 100644 health/src/proto/health_grpc.rs diff --git a/health/Cargo.toml b/health/Cargo.toml index fbf9333e..df3a48a5 100644 --- a/health/Cargo.toml +++ b/health/Cargo.toml @@ -14,8 +14,8 @@ readme = "README.md" [features] default = ["protobuf-codec", "use-bindgen"] -protobuf-codec = ["grpcio/protobuf-codec", "protobuf", "protobuf-build/grpcio-protobuf-codec"] -prost-codec = ["grpcio/prost-codec", "prost", "protobuf-build/grpcio-prost-codec", "lazy_static"] +protobuf-codec = ["grpcio/protobuf-codec", "protobuf"] +prost-codec = ["grpcio/prost-codec", "prost"] use-bindgen = ["grpcio/use-bindgen"] [dependencies] @@ -23,8 +23,4 @@ futures = "0.3" grpcio = { path = "..", features = ["secure"], version = "0.8.0", default-features = false } prost = { version = "0.7", optional = true } protobuf = { version = "2", optional = true } -lazy_static = { version = "1.3", optional = true } log = "0.4" - -[build-dependencies] -protobuf-build = { version = "0.12", default-features = false } diff --git a/health/build.rs b/health/build.rs deleted file mode 100644 index bb02c1dc..00000000 --- a/health/build.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::env; - -fn main() { - let out_dir = env::var("OUT_DIR").unwrap(); - let mut builder = protobuf_build::Builder::new(); - builder - .includes(&["proto".to_owned()]) - .files(&["proto/grpc/health/v1/health.proto"]) - .out_dir(&out_dir); - - #[cfg(feature = "prost-codec")] - builder.wrapper_options(protobuf_build::GenOpt::empty()); - builder.generate(); -} diff --git a/health/proto/grpc/health/v1/health.proto b/health/proto/grpc/health/v1/health.proto deleted file mode 100644 index 38843ff1..00000000 --- a/health/proto/grpc/health/v1/health.proto +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto - -syntax = "proto3"; - -package grpc.health.v1; - -option csharp_namespace = "Grpc.Health.V1"; -option go_package = "google.golang.org/grpc/health/grpc_health_v1"; -option java_multiple_files = true; -option java_outer_classname = "HealthProto"; -option java_package = "io.grpc.health.v1"; - -message HealthCheckRequest { - string service = 1; -} - -message HealthCheckResponse { - enum ServingStatus { - UNKNOWN = 0; - SERVING = 1; - NOT_SERVING = 2; - SERVICE_UNKNOWN = 3; // Used only by the Watch method. - } - ServingStatus status = 1; -} - -service Health { - // If the requested service is unknown, the call will fail with status - // NOT_FOUND. - rpc Check(HealthCheckRequest) returns (HealthCheckResponse); - - // 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 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. - rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); -} diff --git a/health/src/lib.rs b/health/src/lib.rs index e3d79854..f1fb7671 100644 --- a/health/src/lib.rs +++ b/health/src/lib.rs @@ -34,5 +34,5 @@ pub mod proto; mod service; -pub use self::proto::{create_health, HealthClient}; +pub use self::proto::{create_health, HealthClient, ServingStatus}; pub use self::service::HealthService; diff --git a/health/src/proto.rs b/health/src/proto.rs index bc4346b8..244a014a 100644 --- a/health/src/proto.rs +++ b/health/src/proto.rs @@ -2,32 +2,20 @@ #[cfg(feature = "prost-codec")] mod reexports { - include!(concat!(env!("OUT_DIR"), "/mod.rs")); + include!("proto/grpc.health.v1.rs"); - pub use self::grpc::health::v1::*; pub use self::health_check_response::ServingStatus; } #[cfg(feature = "protobuf-codec")] -#[allow(non_upper_case_globals)] +#[allow(deprecated)] +mod health; +#[cfg(feature = "protobuf-codec")] +mod health_grpc; +#[cfg(feature = "protobuf-codec")] mod reexports { - include!(concat!(env!("OUT_DIR"), "/mod.rs")); - - pub use self::health::*; - pub use self::health_grpc::*; - - impl HealthCheckResponse_ServingStatus { - pub const Unknown: HealthCheckResponse_ServingStatus = - HealthCheckResponse_ServingStatus::UNKNOWN; - pub const Serving: HealthCheckResponse_ServingStatus = - HealthCheckResponse_ServingStatus::SERVING; - pub const NotServing: HealthCheckResponse_ServingStatus = - HealthCheckResponse_ServingStatus::NOT_SERVING; - pub const ServiceUnknown: HealthCheckResponse_ServingStatus = - HealthCheckResponse_ServingStatus::SERVICE_UNKNOWN; - } - - pub use HealthCheckResponse_ServingStatus as ServingStatus; + pub use super::health::*; + pub use HealthCheckResponseServingStatus as ServingStatus; } pub use self::reexports::*; diff --git a/health/src/proto/grpc.health.v1.rs b/health/src/proto/grpc.health.v1.rs new file mode 100644 index 00000000..27235647 --- /dev/null +++ b/health/src/proto/grpc.health.v1.rs @@ -0,0 +1,48 @@ +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HealthCheckRequest { + #[prost(string, tag="1")] + pub service: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HealthCheckResponse { + #[prost(enumeration="health_check_response::ServingStatus", tag="1")] + pub status: i32, +} +/// Nested message and enum types in `HealthCheckResponse`. +pub mod health_check_response { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] + pub enum ServingStatus { + Unknown = 0, + Serving = 1, + NotServing = 2, + /// Used only by the Watch method. + ServiceUnknown = 3, + } +} +const METHOD_HEALTH_CHECK: ::grpcio::Method = ::grpcio::Method{ty: ::grpcio::MethodType::Unary, name: "/grpc.health.v1.Health/Check", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pr_ser, de: ::grpcio::pr_de }, resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pr_ser, de: ::grpcio::pr_de }, }; +const METHOD_HEALTH_WATCH: ::grpcio::Method = ::grpcio::Method{ty: ::grpcio::MethodType::ServerStreaming, name: "/grpc.health.v1.Health/Watch", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pr_ser, de: ::grpcio::pr_de }, resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pr_ser, de: ::grpcio::pr_de }, }; +#[derive(Clone)] +pub struct HealthClient { client: ::grpcio::Client } +impl HealthClient { +pub fn new(channel: ::grpcio::Channel) -> Self { HealthClient { client: ::grpcio::Client::new(channel) }} +pub fn check_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_HEALTH_CHECK, req, opt) } +pub fn check(&self, req: &HealthCheckRequest) -> ::grpcio::Result { self.check_opt(req, ::grpcio::CallOption::default()) } +pub fn check_async_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver,> { self.client.unary_call_async(&METHOD_HEALTH_CHECK, req, opt) } +pub fn check_async(&self, req: &HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver,> { self.check_async_opt(req, ::grpcio::CallOption::default()) } +pub fn watch_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver,> { self.client.server_streaming(&METHOD_HEALTH_WATCH, req, opt) } +pub fn watch(&self, req: &HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver,> { self.watch_opt(req, ::grpcio::CallOption::default()) } +pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static {self.client.spawn(f)} +} +pub trait Health { +fn check(&mut self, ctx: ::grpcio::RpcContext, req: HealthCheckRequest, sink: ::grpcio::UnarySink); +fn watch(&mut self, ctx: ::grpcio::RpcContext, req: HealthCheckRequest, sink: ::grpcio::ServerStreamingSink); +} +pub fn create_health(s: S) -> ::grpcio::Service { +let mut builder = ::grpcio::ServiceBuilder::new(); +let mut instance = s.clone(); +builder = builder.add_unary_handler(&METHOD_HEALTH_CHECK, move |ctx, req, resp| instance.check(ctx, req, resp)); +let mut instance = s; +builder = builder.add_server_streaming_handler(&METHOD_HEALTH_WATCH, move |ctx, req, resp| instance.watch(ctx, req, resp)); +builder.build() +} diff --git a/health/src/proto/health.rs b/health/src/proto/health.rs new file mode 100644 index 00000000..22996706 --- /dev/null +++ b/health/src/proto/health.rs @@ -0,0 +1,514 @@ +// This file is generated by rust-protobuf 2.8.0. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `grpc/health/v1/health.proto` + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_0; + +#[derive(PartialEq,Clone,Default)] +pub struct HealthCheckRequest { + // message fields + pub service: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a HealthCheckRequest { + fn default() -> &'a HealthCheckRequest { + ::default_instance() + } +} + +impl HealthCheckRequest { + pub fn new() -> HealthCheckRequest { + ::std::default::Default::default() + } + + // string service = 1; + + + pub fn get_service(&self) -> &str { + &self.service + } + pub fn clear_service(&mut self) { + self.service.clear(); + } + + // Param is passed by value, moved + pub fn set_service(&mut self, v: ::std::string::String) { + self.service = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_service(&mut self) -> &mut ::std::string::String { + &mut self.service + } + + // Take field + pub fn take_service(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.service, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for HealthCheckRequest { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.service)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.service.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.service); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.service.is_empty() { + os.write_string(1, &self.service)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> HealthCheckRequest { + HealthCheckRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "service", + |m: &HealthCheckRequest| { &m.service }, + |m: &mut HealthCheckRequest| { &mut m.service }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "HealthCheckRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static HealthCheckRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const HealthCheckRequest, + }; + unsafe { + instance.get(HealthCheckRequest::new) + } + } +} + +impl ::protobuf::Clear for HealthCheckRequest { + fn clear(&mut self) { + self.service.clear(); + self.unknown_fields.clear(); + } +} +impl ::std::fmt::Debug for HealthCheckRequest { + #[allow(unused_variables)] + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for HealthCheckRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct HealthCheckResponse { + // message fields + pub status: HealthCheckResponseServingStatus, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a HealthCheckResponse { + fn default() -> &'a HealthCheckResponse { + ::default_instance() + } +} + +impl HealthCheckResponse { + pub fn new() -> HealthCheckResponse { + ::std::default::Default::default() + } + + // .grpc.health.v1.HealthCheckResponse.ServingStatus status = 1; + + + pub fn get_status(&self) -> HealthCheckResponseServingStatus { + self.status + } + pub fn clear_status(&mut self) { + self.status = HealthCheckResponseServingStatus::Unknown; + } + + // Param is passed by value, moved + pub fn set_status(&mut self, v: HealthCheckResponseServingStatus) { + self.status = v; + } +} + +impl ::protobuf::Message for HealthCheckResponse { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type == ::protobuf::wire_format::WireTypeVarint {self.status = is.read_enum()?;} else {return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));} + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.status != HealthCheckResponseServingStatus::Unknown { + my_size += ::protobuf::rt::enum_size(1, self.status); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.status != HealthCheckResponseServingStatus::Unknown { + os.write_enum(1, self.status.value())?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> HealthCheckResponse { + HealthCheckResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "status", + |m: &HealthCheckResponse| { &m.status }, + |m: &mut HealthCheckResponse| { &mut m.status }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "HealthCheckResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static HealthCheckResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const HealthCheckResponse, + }; + unsafe { + instance.get(HealthCheckResponse::new) + } + } +} + +impl ::protobuf::Clear for HealthCheckResponse { + fn clear(&mut self) { + self.status = HealthCheckResponseServingStatus::Unknown; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for HealthCheckResponse { + #[allow(unused_variables)] + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for HealthCheckResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum HealthCheckResponseServingStatus { + Unknown = 0, + Serving = 1, + NotServing = 2, + ServiceUnknown = 3, +} + +impl ::protobuf::ProtobufEnum for HealthCheckResponseServingStatus { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(HealthCheckResponseServingStatus::Unknown), + 1 => ::std::option::Option::Some(HealthCheckResponseServingStatus::Serving), + 2 => ::std::option::Option::Some(HealthCheckResponseServingStatus::NotServing), + 3 => ::std::option::Option::Some(HealthCheckResponseServingStatus::ServiceUnknown), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [HealthCheckResponseServingStatus] = &[ + HealthCheckResponseServingStatus::Unknown, + HealthCheckResponseServingStatus::Serving, + HealthCheckResponseServingStatus::NotServing, + HealthCheckResponseServingStatus::ServiceUnknown, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("HealthCheckResponseServingStatus", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for HealthCheckResponseServingStatus { +} + +impl ::std::default::Default for HealthCheckResponseServingStatus { + fn default() -> Self { + HealthCheckResponseServingStatus::Unknown + } +} + +impl ::protobuf::reflect::ProtobufValue for HealthCheckResponseServingStatus { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1bgrpc/health/v1/health.proto\x12\x0egrpc.health.v1\".\n\x12HealthCh\ + eckRequest\x12\x18\n\x07service\x18\x01\x20\x01(\tR\x07service\"\xb1\x01\ + \n\x13HealthCheckResponse\x12I\n\x06status\x18\x01\x20\x01(\x0e21.grpc.h\ + ealth.v1.HealthCheckResponse.ServingStatusR\x06status\"O\n\rServingStatu\ + s\x12\x0b\n\x07UNKNOWN\x10\0\x12\x0b\n\x07SERVING\x10\x01\x12\x0f\n\x0bN\ + OT_SERVING\x10\x02\x12\x13\n\x0fSERVICE_UNKNOWN\x10\x032\xae\x01\n\x06He\ + alth\x12P\n\x05Check\x12\".grpc.health.v1.HealthCheckRequest\x1a#.grpc.h\ + ealth.v1.HealthCheckResponse\x12R\n\x05Watch\x12\".grpc.health.v1.Health\ + CheckRequest\x1a#.grpc.health.v1.HealthCheckResponse0\x01Ba\n\x11io.grpc\ + .health.v1B\x0bHealthProtoP\x01Z,google.golang.org/grpc/health/grpc_heal\ + th_v1\xaa\x02\x0eGrpc.Health.V1J\xb5\x12\n\x06\x12\x04\x11\0>\x01\n\xc6\ + \x05\n\x01\x0c\x12\x03\x11\0\x122\xb7\x04\x20Copyright\x202015\x20The\ + \x20gRPC\x20Authors\n\n\x20Licensed\x20under\x20the\x20Apache\x20License\ + ,\x20Version\x202.0\x20(the\x20\"License\");\n\x20you\x20may\x20not\x20u\ + se\x20this\x20file\x20except\x20in\x20compliance\x20with\x20the\x20Licen\ + se.\n\x20You\x20may\x20obtain\x20a\x20copy\x20of\x20the\x20License\x20at\ + \n\n\x20\x20\x20\x20\x20http://www.apache.org/licenses/LICENSE-2.0\n\n\ + \x20Unless\x20required\x20by\x20applicable\x20law\x20or\x20agreed\x20to\ + \x20in\x20writing,\x20software\n\x20distributed\x20under\x20the\x20Licen\ + se\x20is\x20distributed\x20on\x20an\x20\"AS\x20IS\"\x20BASIS,\n\x20WITHO\ + UT\x20WARRANTIES\x20OR\x20CONDITIONS\x20OF\x20ANY\x20KIND,\x20either\x20\ + express\x20or\x20implied.\n\x20See\x20the\x20License\x20for\x20the\x20sp\ + ecific\x20language\x20governing\x20permissions\x20and\n\x20limitations\ + \x20under\x20the\x20License.\n2\x81\x01\x20The\x20canonical\x20version\ + \x20of\x20this\x20proto\x20can\x20be\x20found\x20at\n\x20https://github.\ + com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto\n\n\x08\n\ + \x01\x02\x12\x03\x13\0\x17\n\x08\n\x01\x08\x12\x03\x15\0+\n\t\n\x02\x08%\ + \x12\x03\x15\0+\n\x08\n\x01\x08\x12\x03\x16\0C\n\t\n\x02\x08\x0b\x12\x03\ + \x16\0C\n\x08\n\x01\x08\x12\x03\x17\0\"\n\t\n\x02\x08\n\x12\x03\x17\0\"\ + \n\x08\n\x01\x08\x12\x03\x18\0,\n\t\n\x02\x08\x08\x12\x03\x18\0,\n\x08\n\ + \x01\x08\x12\x03\x19\0*\n\t\n\x02\x08\x01\x12\x03\x19\0*\n\n\n\x02\x04\0\ + \x12\x04\x1b\0\x1d\x01\n\n\n\x03\x04\0\x01\x12\x03\x1b\x08\x1a\n\x0b\n\ + \x04\x04\0\x02\0\x12\x03\x1c\x02\x15\n\r\n\x05\x04\0\x02\0\x04\x12\x04\ + \x1c\x02\x1b\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x1c\x02\x08\n\x0c\n\ + \x05\x04\0\x02\0\x01\x12\x03\x1c\t\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\ + \x03\x1c\x13\x14\n\n\n\x02\x04\x01\x12\x04\x1f\0'\x01\n\n\n\x03\x04\x01\ + \x01\x12\x03\x1f\x08\x1b\n\x0c\n\x04\x04\x01\x04\0\x12\x04\x20\x02%\x03\ + \n\x0c\n\x05\x04\x01\x04\0\x01\x12\x03\x20\x07\x14\n\r\n\x06\x04\x01\x04\ + \0\x02\0\x12\x03!\x04\x10\n\x0e\n\x07\x04\x01\x04\0\x02\0\x01\x12\x03!\ + \x04\x0b\n\x0e\n\x07\x04\x01\x04\0\x02\0\x02\x12\x03!\x0e\x0f\n\r\n\x06\ + \x04\x01\x04\0\x02\x01\x12\x03\"\x04\x10\n\x0e\n\x07\x04\x01\x04\0\x02\ + \x01\x01\x12\x03\"\x04\x0b\n\x0e\n\x07\x04\x01\x04\0\x02\x01\x02\x12\x03\ + \"\x0e\x0f\n\r\n\x06\x04\x01\x04\0\x02\x02\x12\x03#\x04\x14\n\x0e\n\x07\ + \x04\x01\x04\0\x02\x02\x01\x12\x03#\x04\x0f\n\x0e\n\x07\x04\x01\x04\0\ + \x02\x02\x02\x12\x03#\x12\x13\n/\n\x06\x04\x01\x04\0\x02\x03\x12\x03$\ + \x04\x18\"\x20\x20Used\x20only\x20by\x20the\x20Watch\x20method.\n\n\x0e\ + \n\x07\x04\x01\x04\0\x02\x03\x01\x12\x03$\x04\x13\n\x0e\n\x07\x04\x01\ + \x04\0\x02\x03\x02\x12\x03$\x16\x17\n\x0b\n\x04\x04\x01\x02\0\x12\x03&\ + \x02\x1b\n\r\n\x05\x04\x01\x02\0\x04\x12\x04&\x02%\x03\n\x0c\n\x05\x04\ + \x01\x02\0\x06\x12\x03&\x02\x0f\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03&\ + \x10\x16\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03&\x19\x1a\n\n\n\x02\x06\0\ + \x12\x04)\0>\x01\n\n\n\x03\x06\0\x01\x12\x03)\x08\x0e\n^\n\x04\x06\0\x02\ + \0\x12\x03,\x02>\x1aQ\x20If\x20the\x20requested\x20service\x20is\x20unkn\ + own,\x20the\x20call\x20will\x20fail\x20with\x20status\n\x20NOT_FOUND.\n\ + \n\x0c\n\x05\x06\0\x02\0\x01\x12\x03,\x06\x0b\n\x0c\n\x05\x06\0\x02\0\ + \x02\x12\x03,\x0c\x1e\n\x0c\n\x05\x06\0\x02\0\x03\x12\x03,)<\n\xde\x06\n\ + \x04\x06\0\x02\x01\x12\x03=\x02E\x1a\xd0\x06\x20Performs\x20a\x20watch\ + \x20for\x20the\x20serving\x20status\x20of\x20the\x20requested\x20service\ + .\n\x20The\x20server\x20will\x20immediately\x20send\x20back\x20a\x20mess\ + age\x20indicating\x20the\x20current\n\x20serving\x20status.\x20\x20It\ + \x20will\x20then\x20subsequently\x20send\x20a\x20new\x20message\x20whene\ + ver\n\x20the\x20service's\x20serving\x20status\x20changes.\n\n\x20If\x20\ + the\x20requested\x20service\x20is\x20unknown\x20when\x20the\x20call\x20i\ + s\x20received,\x20the\n\x20server\x20will\x20send\x20a\x20message\x20set\ + ting\x20the\x20serving\x20status\x20to\n\x20SERVICE_UNKNOWN\x20but\x20wi\ + ll\x20*not*\x20terminate\x20the\x20call.\x20\x20If\x20at\x20some\n\x20fu\ + ture\x20point,\x20the\x20serving\x20status\x20of\x20the\x20service\x20be\ + comes\x20known,\x20the\n\x20server\x20will\x20send\x20a\x20new\x20messag\ + e\x20with\x20the\x20service's\x20serving\x20status.\n\n\x20If\x20the\x20\ + call\x20terminates\x20with\x20status\x20UNIMPLEMENTED,\x20then\x20client\ + s\n\x20should\x20assume\x20this\x20method\x20is\x20not\x20supported\x20a\ + nd\x20should\x20not\x20retry\x20the\n\x20call.\x20\x20If\x20the\x20call\ + \x20terminates\x20with\x20any\x20other\x20status\x20(including\x20OK),\n\ + \x20clients\x20should\x20retry\x20the\x20call\x20with\x20appropriate\x20\ + exponential\x20backoff.\n\n\x0c\n\x05\x06\0\x02\x01\x01\x12\x03=\x06\x0b\ + \n\x0c\n\x05\x06\0\x02\x01\x02\x12\x03=\x0c\x1e\n\x0c\n\x05\x06\0\x02\ + \x01\x06\x12\x03=)/\n\x0c\n\x05\x06\0\x02\x01\x03\x12\x03=0Cb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} +pub use super::health_grpc::*; diff --git a/health/src/proto/health_grpc.rs b/health/src/proto/health_grpc.rs new file mode 100644 index 00000000..ec6a8b4e --- /dev/null +++ b/health/src/proto/health_grpc.rs @@ -0,0 +1,140 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_HEALTH_CHECK: ::grpcio::Method< + super::health::HealthCheckRequest, + super::health::HealthCheckResponse, +> = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/grpc.health.v1.Health/Check", + req_mar: ::grpcio::Marshaller { + ser: ::grpcio::pb_ser, + de: ::grpcio::pb_de, + }, + resp_mar: ::grpcio::Marshaller { + ser: ::grpcio::pb_ser, + de: ::grpcio::pb_de, + }, +}; + +const METHOD_HEALTH_WATCH: ::grpcio::Method< + super::health::HealthCheckRequest, + super::health::HealthCheckResponse, +> = ::grpcio::Method { + ty: ::grpcio::MethodType::ServerStreaming, + name: "/grpc.health.v1.Health/Watch", + req_mar: ::grpcio::Marshaller { + ser: ::grpcio::pb_ser, + de: ::grpcio::pb_de, + }, + resp_mar: ::grpcio::Marshaller { + ser: ::grpcio::pb_ser, + de: ::grpcio::pb_de, + }, +}; + +#[derive(Clone)] +pub struct HealthClient { + client: ::grpcio::Client, +} + +impl HealthClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + HealthClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn check_opt( + &self, + req: &super::health::HealthCheckRequest, + opt: ::grpcio::CallOption, + ) -> ::grpcio::Result { + self.client.unary_call(&METHOD_HEALTH_CHECK, req, opt) + } + + pub fn check( + &self, + req: &super::health::HealthCheckRequest, + ) -> ::grpcio::Result { + self.check_opt(req, ::grpcio::CallOption::default()) + } + + pub fn check_async_opt( + &self, + req: &super::health::HealthCheckRequest, + opt: ::grpcio::CallOption, + ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_HEALTH_CHECK, req, opt) + } + + pub fn check_async( + &self, + req: &super::health::HealthCheckRequest, + ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.check_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn watch_opt( + &self, + req: &super::health::HealthCheckRequest, + opt: ::grpcio::CallOption, + ) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver> { + self.client.server_streaming(&METHOD_HEALTH_WATCH, req, opt) + } + + pub fn watch( + &self, + req: &super::health::HealthCheckRequest, + ) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver> { + self.watch_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) + where + F: ::futures::Future + Send + 'static, + { + self.client.spawn(f) + } +} + +pub trait Health { + fn check( + &mut self, + ctx: ::grpcio::RpcContext, + req: super::health::HealthCheckRequest, + sink: ::grpcio::UnarySink, + ); + fn watch( + &mut self, + ctx: ::grpcio::RpcContext, + req: super::health::HealthCheckRequest, + sink: ::grpcio::ServerStreamingSink, + ); +} + +pub fn create_health(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_HEALTH_CHECK, move |ctx, req, resp| { + instance.check(ctx, req, resp) + }); + let mut instance = s; + builder = builder.add_server_streaming_handler(&METHOD_HEALTH_WATCH, move |ctx, req, resp| { + instance.watch(ctx, req, resp) + }); + builder.build() +}