|
| 1 | +#[derive(Clone, PartialEq, ::prost::Message)] |
| 2 | +pub struct HealthCheckRequest { |
| 3 | + #[prost(string, tag="1")] |
| 4 | + pub service: ::prost::alloc::string::String, |
| 5 | +} |
| 6 | +#[derive(Clone, PartialEq, ::prost::Message)] |
| 7 | +pub struct HealthCheckResponse { |
| 8 | + #[prost(enumeration="health_check_response::ServingStatus", tag="1")] |
| 9 | + pub status: i32, |
| 10 | +} |
| 11 | +/// Nested message and enum types in `HealthCheckResponse`. |
| 12 | +pub mod health_check_response { |
| 13 | + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] |
| 14 | + #[repr(i32)] |
| 15 | + pub enum ServingStatus { |
| 16 | + Unknown = 0, |
| 17 | + Serving = 1, |
| 18 | + NotServing = 2, |
| 19 | + /// Used only by the Watch method. |
| 20 | + ServiceUnknown = 3, |
| 21 | + } |
| 22 | +} |
| 23 | +const METHOD_HEALTH_CHECK: ::grpcio::Method<HealthCheckRequest, HealthCheckResponse> = ::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 }, }; |
| 24 | +const METHOD_HEALTH_WATCH: ::grpcio::Method<HealthCheckRequest, HealthCheckResponse> = ::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 }, }; |
| 25 | +#[derive(Clone)] |
| 26 | +pub struct HealthClient { client: ::grpcio::Client } |
| 27 | +impl HealthClient { |
| 28 | +pub fn new(channel: ::grpcio::Channel) -> Self { HealthClient { client: ::grpcio::Client::new(channel) }} |
| 29 | +pub fn check_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<HealthCheckResponse,> { self.client.unary_call(&METHOD_HEALTH_CHECK, req, opt) } |
| 30 | +pub fn check(&self, req: &HealthCheckRequest) -> ::grpcio::Result<HealthCheckResponse,> { self.check_opt(req, ::grpcio::CallOption::default()) } |
| 31 | +pub fn check_async_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<HealthCheckResponse>,> { self.client.unary_call_async(&METHOD_HEALTH_CHECK, req, opt) } |
| 32 | +pub fn check_async(&self, req: &HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<HealthCheckResponse>,> { self.check_async_opt(req, ::grpcio::CallOption::default()) } |
| 33 | +pub fn watch_opt(&self, req: &HealthCheckRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<HealthCheckResponse>,> { self.client.server_streaming(&METHOD_HEALTH_WATCH, req, opt) } |
| 34 | +pub fn watch(&self, req: &HealthCheckRequest) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<HealthCheckResponse>,> { self.watch_opt(req, ::grpcio::CallOption::default()) } |
| 35 | +pub fn spawn<F>(&self, f: F) where F: ::futures::Future<Output = ()> + Send + 'static {self.client.spawn(f)} |
| 36 | +} |
| 37 | +pub trait Health { |
| 38 | +fn check(&mut self, ctx: ::grpcio::RpcContext, req: HealthCheckRequest, sink: ::grpcio::UnarySink<HealthCheckResponse>); |
| 39 | +fn watch(&mut self, ctx: ::grpcio::RpcContext, req: HealthCheckRequest, sink: ::grpcio::ServerStreamingSink<HealthCheckResponse>); |
| 40 | +} |
| 41 | +pub fn create_health<S: Health + Send + Clone + 'static>(s: S) -> ::grpcio::Service { |
| 42 | +let mut builder = ::grpcio::ServiceBuilder::new(); |
| 43 | +let mut instance = s.clone(); |
| 44 | +builder = builder.add_unary_handler(&METHOD_HEALTH_CHECK, move |ctx, req, resp| instance.check(ctx, req, resp)); |
| 45 | +let mut instance = s; |
| 46 | +builder = builder.add_server_streaming_handler(&METHOD_HEALTH_WATCH, move |ctx, req, resp| instance.watch(ctx, req, resp)); |
| 47 | +builder.build() |
| 48 | +} |
0 commit comments