default_health_check_service.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <stddef.h>
22 #include <stdint.h>
23 
24 #include <memory>
25 #include <utility>
26 
27 #include "absl/memory/memory.h"
28 #include "upb/upb.h"
29 #include "upb/upb.hpp"
30 
31 #include <grpc/slice.h>
32 #include <grpc/support/log.h>
33 #include <grpcpp/impl/rpc_method.h>
35 #include <grpcpp/support/slice.h>
36 
38 
39 #define MAX_SERVICE_NAME_LENGTH 200
40 
41 namespace grpc {
42 
43 //
44 // DefaultHealthCheckService
45 //
46 
48  services_map_[""].SetServingStatus(SERVING);
49 }
50 
52  const std::string& service_name, bool serving) {
54  if (shutdown_) {
55  // Set to NOT_SERVING in case service_name is not in the map.
56  serving = false;
57  }
58  services_map_[service_name].SetServingStatus(serving ? SERVING : NOT_SERVING);
59 }
60 
62  const ServingStatus status = serving ? SERVING : NOT_SERVING;
64  if (shutdown_) {
65  return;
66  }
67  for (auto& p : services_map_) {
68  ServiceData& service_data = p.second;
69  service_data.SetServingStatus(status);
70  }
71 }
72 
75  if (shutdown_) {
76  return;
77  }
78  shutdown_ = true;
79  for (auto& p : services_map_) {
80  ServiceData& service_data = p.second;
81  service_data.SetServingStatus(NOT_SERVING);
82  }
83 }
84 
87  const std::string& service_name) const {
89  auto it = services_map_.find(service_name);
90  if (it == services_map_.end()) {
91  return NOT_FOUND;
92  }
93  const ServiceData& service_data = it->second;
94  return service_data.GetServingStatus();
95 }
96 
98  const std::string& service_name,
99  std::shared_ptr<HealthCheckServiceImpl::CallHandler> handler) {
100  grpc_core::MutexLock lock(&mu_);
101  ServiceData& service_data = services_map_[service_name];
102  service_data.AddCallHandler(handler /* copies ref */);
104  h->SendHealth(std::move(handler), service_data.GetServingStatus());
105 }
106 
108  const std::string& service_name,
109  const std::shared_ptr<HealthCheckServiceImpl::CallHandler>& handler) {
110  grpc_core::MutexLock lock(&mu_);
111  auto it = services_map_.find(service_name);
112  if (it == services_map_.end()) return;
113  ServiceData& service_data = it->second;
114  service_data.RemoveCallHandler(handler);
115  if (service_data.Unused()) {
116  services_map_.erase(it);
117  }
118 }
119 
122  std::unique_ptr<ServerCompletionQueue> cq) {
123  GPR_ASSERT(impl_ == nullptr);
124  impl_ = absl::make_unique<HealthCheckServiceImpl>(this, std::move(cq));
125  return impl_.get();
126 }
127 
128 //
129 // DefaultHealthCheckService::ServiceData
130 //
131 
134  status_ = status;
135  for (auto& call_handler : call_handlers_) {
136  call_handler->SendHealth(call_handler /* copies ref */, status);
137  }
138 }
139 
141  std::shared_ptr<HealthCheckServiceImpl::CallHandler> handler) {
142  call_handlers_.insert(std::move(handler));
143 }
144 
146  const std::shared_ptr<HealthCheckServiceImpl::CallHandler>& handler) {
147  call_handlers_.erase(handler);
148 }
149 
150 //
151 // DefaultHealthCheckService::HealthCheckServiceImpl
152 //
153 
154 namespace {
155 const char kHealthCheckMethodName[] = "/grpc.health.v1.Health/Check";
156 const char kHealthWatchMethodName[] = "/grpc.health.v1.Health/Watch";
157 } // namespace
158 
161  std::unique_ptr<ServerCompletionQueue> cq)
162  : database_(database), cq_(std::move(cq)) {
163  // Add Check() method.
165  kHealthCheckMethodName, internal::RpcMethod::NORMAL_RPC, nullptr));
166  // Add Watch() method.
168  kHealthWatchMethodName, internal::RpcMethod::SERVER_STREAMING, nullptr));
169  // Create serving thread.
170  thread_ = absl::make_unique<grpc_core::Thread>("grpc_health_check_service",
171  Serve, this);
172 }
173 
175  // We will reach here after the server starts shutting down.
176  shutdown_ = true;
177  {
178  grpc_core::MutexLock lock(&cq_shutdown_mu_);
179  cq_->Shutdown();
180  }
181  thread_->Join();
182 }
183 
185  // Request the calls we're interested in.
186  // We do this before starting the serving thread, so that we know it's
187  // done before server startup is complete.
188  CheckCallHandler::CreateAndStart(cq_.get(), database_, this);
189  WatchCallHandler::CreateAndStart(cq_.get(), database_, this);
190  // Start serving thread.
191  thread_->Start();
192 }
193 
196  void* tag;
197  bool ok;
198  while (true) {
199  if (!service->cq_->Next(&tag, &ok)) {
200  // The completion queue is shutting down.
201  GPR_ASSERT(service->shutdown_);
202  break;
203  }
204  auto* next_step = static_cast<CallableTag*>(tag);
205  next_step->Run(ok);
206  }
207 }
208 
210  const ByteBuffer& request, std::string* service_name) {
211  Slice slice;
212  if (!request.DumpToSingleSlice(&slice).ok()) return false;
213  uint8_t* request_bytes = nullptr;
214  size_t request_size = 0;
215  request_bytes = const_cast<uint8_t*>(slice.begin());
216  request_size = slice.size();
218  grpc_health_v1_HealthCheckRequest* request_struct =
220  reinterpret_cast<char*>(request_bytes), request_size, arena.ptr());
221  if (request_struct == nullptr) {
222  return false;
223  }
226  if (service.size > MAX_SERVICE_NAME_LENGTH) {
227  return false;
228  }
229  service_name->assign(service.data, service.size);
230  return true;
231 }
232 
236  grpc_health_v1_HealthCheckResponse* response_struct =
239  response_struct,
243  size_t buf_length;
245  response_struct, arena.ptr(), &buf_length);
246  if (buf == nullptr) {
247  return false;
248  }
249  grpc_slice response_slice = grpc_slice_from_copied_buffer(buf, buf_length);
250  Slice encoded_response(response_slice, Slice::STEAL_REF);
251  ByteBuffer response_buffer(&encoded_response, 1);
252  response->Swap(&response_buffer);
253  return true;
254 }
255 
256 //
257 // DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler
258 //
259 
264  std::shared_ptr<CallHandler> self =
265  std::make_shared<CheckCallHandler>(cq, database, service);
266  CheckCallHandler* handler = static_cast<CheckCallHandler*>(self.get());
267  {
268  grpc_core::MutexLock lock(&service->cq_shutdown_mu_);
269  if (service->shutdown_) return;
270  // Request a Check() call.
271  handler->next_ =
272  CallableTag(std::bind(&CheckCallHandler::OnCallReceived, handler,
273  std::placeholders::_1, std::placeholders::_2),
274  std::move(self));
275  service->RequestAsyncUnary(0, &handler->ctx_, &handler->request_,
276  &handler->writer_, cq, cq, &handler->next_);
277  }
278 }
279 
284  : cq_(cq), database_(database), service_(service), writer_(&ctx_) {}
285 
287  OnCallReceived(std::shared_ptr<CallHandler> self, bool ok) {
288  if (!ok) {
289  // The value of ok being false means that the server is shutting down.
290  return;
291  }
292  // Spawn a new handler instance to serve the next new client. Every handler
293  // instance will deallocate itself when it's done.
294  CreateAndStart(cq_, database_, service_);
295  // Process request.
296  gpr_log(GPR_DEBUG, "[HCS %p] Health check started for handler %p", service_,
297  this);
298  std::string service_name;
301  if (!service_->DecodeRequest(request_, &service_name)) {
302  status = Status(StatusCode::INVALID_ARGUMENT, "could not parse request");
303  } else {
304  ServingStatus serving_status = database_->GetServingStatus(service_name);
305  if (serving_status == NOT_FOUND) {
306  status = Status(StatusCode::NOT_FOUND, "service name unknown");
307  } else if (!service_->EncodeResponse(serving_status, &response)) {
308  status = Status(StatusCode::INTERNAL, "could not encode response");
309  }
310  }
311  // Send response.
312  {
313  grpc_core::MutexLock lock(&service_->cq_shutdown_mu_);
314  if (!service_->shutdown_) {
315  next_ =
317  std::placeholders::_1, std::placeholders::_2),
318  std::move(self));
319  if (status.ok()) {
320  writer_.Finish(response, status, &next_);
321  } else {
322  writer_.FinishWithError(status, &next_);
323  }
324  }
325  }
326 }
327 
329  OnFinishDone(std::shared_ptr<CallHandler> self, bool ok) {
330  if (ok) {
331  gpr_log(GPR_DEBUG, "[HCS %p] Health check call finished for handler %p",
332  service_, this);
333  }
334  self.reset(); // To appease clang-tidy.
335 }
336 
337 //
338 // DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler
339 //
340 
345  std::shared_ptr<CallHandler> self =
346  std::make_shared<WatchCallHandler>(cq, database, service);
347  WatchCallHandler* handler = static_cast<WatchCallHandler*>(self.get());
348  {
349  grpc_core::MutexLock lock(&service->cq_shutdown_mu_);
350  if (service->shutdown_) return;
351  // Request AsyncNotifyWhenDone().
352  handler->on_done_notified_ =
354  std::placeholders::_1, std::placeholders::_2),
355  self /* copies ref */);
356  handler->ctx_.AsyncNotifyWhenDone(&handler->on_done_notified_);
357  // Request a Watch() call.
358  handler->next_ =
360  std::placeholders::_1, std::placeholders::_2),
361  std::move(self));
362  service->RequestAsyncServerStreaming(1, &handler->ctx_, &handler->request_,
363  &handler->stream_, cq, cq,
364  &handler->next_);
365  }
366 }
367 
373 
375  OnCallReceived(std::shared_ptr<CallHandler> self, bool ok) {
376  if (!ok) {
377  // Server shutting down.
378  //
379  // AsyncNotifyWhenDone() needs to be called before the call starts, but the
380  // tag will not pop out if the call never starts (
381  // https://github.com/grpc/grpc/issues/10136). So we need to manually
382  // release the ownership of the handler in this case.
383  GPR_ASSERT(on_done_notified_.ReleaseHandler() != nullptr);
384  return;
385  }
386  // Spawn a new handler instance to serve the next new client. Every handler
387  // instance will deallocate itself when it's done.
388  CreateAndStart(cq_, database_, service_);
389  // Parse request.
390  if (!service_->DecodeRequest(request_, &service_name_)) {
391  SendFinish(std::move(self),
392  Status(StatusCode::INVALID_ARGUMENT, "could not parse request"));
393  return;
394  }
395  // Register the call for updates to the service.
397  "[HCS %p] Health watch started for service \"%s\" (handler: %p)",
398  service_, service_name_.c_str(), this);
400 }
401 
403  SendHealth(std::shared_ptr<CallHandler> self, ServingStatus status) {
404  grpc_core::MutexLock lock(&send_mu_);
405  // If there's already a send in flight, cache the new status, and
406  // we'll start a new send for it when the one in flight completes.
407  if (send_in_flight_) {
408  pending_status_ = status;
409  return;
410  }
411  // Start a send.
412  SendHealthLocked(std::move(self), status);
413 }
414 
416  SendHealthLocked(std::shared_ptr<CallHandler> self, ServingStatus status) {
417  send_in_flight_ = true;
418  // Construct response.
420  bool success = service_->EncodeResponse(status, &response);
421  // Grab shutdown lock and send response.
422  grpc_core::MutexLock cq_lock(&service_->cq_shutdown_mu_);
423  if (service_->shutdown_) {
424  SendFinishLocked(std::move(self), Status::CANCELLED);
425  return;
426  }
427  if (!success) {
428  SendFinishLocked(std::move(self),
429  Status(StatusCode::INTERNAL, "could not encode response"));
430  return;
431  }
432  next_ = CallableTag(std::bind(&WatchCallHandler::OnSendHealthDone, this,
433  std::placeholders::_1, std::placeholders::_2),
434  std::move(self));
435  stream_.Write(response, &next_);
436 }
437 
439  OnSendHealthDone(std::shared_ptr<CallHandler> self, bool ok) {
440  if (!ok) {
441  SendFinish(std::move(self), Status::CANCELLED);
442  return;
443  }
444  grpc_core::MutexLock lock(&send_mu_);
445  send_in_flight_ = false;
446  // If we got a new status since we started the last send, start a
447  // new send for it.
448  if (pending_status_ != NOT_FOUND) {
449  auto status = pending_status_;
450  pending_status_ = NOT_FOUND;
451  SendHealthLocked(std::move(self), status);
452  }
453 }
454 
456  SendFinish(std::shared_ptr<CallHandler> self, const Status& status) {
457  if (finish_called_) return;
458  grpc_core::MutexLock cq_lock(&service_->cq_shutdown_mu_);
459  if (service_->shutdown_) return;
460  SendFinishLocked(std::move(self), status);
461 }
462 
464  SendFinishLocked(std::shared_ptr<CallHandler> self, const Status& status) {
465  on_finish_done_ =
467  std::placeholders::_1, std::placeholders::_2),
468  std::move(self));
469  stream_.Finish(status, &on_finish_done_);
470  finish_called_ = true;
471 }
472 
474  OnFinishDone(std::shared_ptr<CallHandler> self, bool ok) {
475  if (ok) {
477  "[HCS %p] Health watch call finished (service_name: \"%s\", "
478  "handler: %p).",
479  service_, service_name_.c_str(), this);
480  }
481  self.reset(); // To appease clang-tidy.
482 }
483 
484 // TODO(roth): This method currently assumes that there will be only one
485 // thread polling the cq and invoking the corresponding callbacks. If
486 // that changes, we will need to add synchronization here.
488  OnDoneNotified(std::shared_ptr<CallHandler> self, bool ok) {
489  GPR_ASSERT(ok);
491  "[HCS %p] Health watch call is notified done (handler: %p, "
492  "is_cancelled: %d).",
493  service_, this, static_cast<int>(ctx_.IsCancelled()));
495  SendFinish(std::move(self), Status::CANCELLED);
496 }
497 
498 } // namespace grpc
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CallHandler
Definition: default_health_check_service.h:56
cq_
grpc_completion_queue * cq_
Definition: channel_connectivity.cc:210
grpc::DefaultHealthCheckService::NOT_SERVING
@ NOT_SERVING
Definition: default_health_check_service.h:50
grpc::status
auto status
Definition: cpp/client/credentials_test.cc:200
grpc::ServerCompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:436
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::SendHealthLocked
void SendHealthLocked(std::shared_ptr< CallHandler > self, ServingStatus status)
Definition: default_health_check_service.cc:416
regen-readme.it
it
Definition: regen-readme.py:15
log.h
grpc::Status::CANCELLED
static const Status & CANCELLED
A CANCELLED pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:115
grpc::DefaultHealthCheckService::impl_
std::unique_ptr< HealthCheckServiceImpl > impl_
Definition: default_health_check_service.h:286
grpc
Definition: grpcpp/alarm.h:33
stream_
std::unique_ptr< grpc::ClientReaderInterface< OrcaLoadReport > > stream_
Definition: orca_service_end2end_test.cc:89
slice.h
grpc_core::MutexLock
Definition: src/core/lib/gprpp/sync.h:88
grpc::DefaultHealthCheckService::ServiceData::GetServingStatus
ServingStatus GetServingStatus() const
Definition: default_health_check_service.h:260
grpc::DefaultHealthCheckService::RegisterCallHandler
void RegisterCallHandler(const std::string &service_name, std::shared_ptr< HealthCheckServiceImpl::CallHandler > handler)
Definition: default_health_check_service.cc:97
benchmark.request
request
Definition: benchmark.py:77
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc::DefaultHealthCheckService::ServingStatus
ServingStatus
Definition: default_health_check_service.h:50
grpc::DefaultHealthCheckService::NOT_FOUND
@ NOT_FOUND
Definition: default_health_check_service.h:50
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler::OnCallReceived
void OnCallReceived(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:287
slice.h
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CallableTag::Run
void Run(bool ok)
Definition: default_health_check_service.h:93
rpc_service_method.h
rpc_method.h
ctx_
ClientContext ctx_
Definition: client_interceptors_end2end_test.cc:289
grpc::DefaultHealthCheckService::UnregisterCallHandler
void UnregisterCallHandler(const std::string &service_name, const std::shared_ptr< HealthCheckServiceImpl::CallHandler > &handler)
Definition: default_health_check_service.cc:107
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::CreateAndStart
static void CreateAndStart(ServerCompletionQueue *cq, DefaultHealthCheckService *database, HealthCheckServiceImpl *service)
Definition: default_health_check_service.cc:342
grpc::DefaultHealthCheckService::GetHealthCheckService
HealthCheckServiceImpl * GetHealthCheckService(std::unique_ptr< ServerCompletionQueue > cq)
Definition: default_health_check_service.cc:121
grpc::DefaultHealthCheckService::mu_
grpc_core::Mutex mu_
Definition: default_health_check_service.h:283
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::DecodeRequest
static bool DecodeRequest(const ByteBuffer &request, std::string *service_name)
Definition: default_health_check_service.cc:209
grpc::Slice::STEAL_REF
@ STEAL_REF
Definition: include/grpcpp/impl/codegen/slice.h:48
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::database_
DefaultHealthCheckService * database_
Definition: default_health_check_service.h:232
grpc_health_v1_HealthCheckResponse_SERVICE_UNKNOWN
@ grpc_health_v1_HealthCheckResponse_SERVICE_UNKNOWN
Definition: health.upb.h:34
grpc_health_v1_HealthCheckResponse_SERVING
@ grpc_health_v1_HealthCheckResponse_SERVING
Definition: health.upb.h:32
grpc_health_v1_HealthCheckResponse_serialize
UPB_INLINE char * grpc_health_v1_HealthCheckResponse_serialize(const grpc_health_v1_HealthCheckResponse *msg, upb_Arena *arena, size_t *len)
Definition: health.upb.h:105
grpc::internal::RpcServiceMethod
Server side rpc method class.
Definition: grpcpp/impl/codegen/rpc_service_method.h:86
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::thread_
std::unique_ptr< grpc_core::Thread > thread_
Definition: default_health_check_service.h:239
grpc::internal::RpcMethod::NORMAL_RPC
@ NORMAL_RPC
Definition: grpcpp/impl/codegen/rpc_method.h:34
grpc::DefaultHealthCheckService::ServiceData
Definition: default_health_check_service.h:257
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler
Definition: default_health_check_service.h:113
grpc::DefaultHealthCheckService::services_map_
std::map< std::string, ServiceData > services_map_
Definition: default_health_check_service.h:285
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CallableTag
Definition: default_health_check_service.h:78
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler::CreateAndStart
static void CreateAndStart(ServerCompletionQueue *cq, DefaultHealthCheckService *database, HealthCheckServiceImpl *service)
Definition: default_health_check_service.cc:261
grpc_health_v1_HealthCheckResponse
struct grpc_health_v1_HealthCheckResponse grpc_health_v1_HealthCheckResponse
Definition: health.upb.h:26
grpc::DefaultHealthCheckService::DefaultHealthCheckService
DefaultHealthCheckService()
Definition: default_health_check_service.cc:47
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::OnFinishDone
void OnFinishDone(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:474
grpc_health_v1_HealthCheckRequest_parse
UPB_INLINE grpc_health_v1_HealthCheckRequest * grpc_health_v1_HealthCheckRequest_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: health.upb.h:44
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::OnCallReceived
void OnCallReceived(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:375
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
upb.h
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc::DefaultHealthCheckService::ServiceData::AddCallHandler
void AddCallHandler(std::shared_ptr< HealthCheckServiceImpl::CallHandler > handler)
Definition: default_health_check_service.cc:140
grpc.StatusCode.NOT_FOUND
tuple NOT_FOUND
Definition: src/python/grpcio/grpc/__init__.py:266
service_name_
std::string service_name_
Definition: health_check_client.cc:153
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::SendHealth
void SendHealth(std::shared_ptr< CallHandler > self, ServingStatus status) override
Definition: default_health_check_service.cc:403
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::HealthCheckServiceImpl
HealthCheckServiceImpl(DefaultHealthCheckService *database, std::unique_ptr< ServerCompletionQueue > cq)
Definition: default_health_check_service.cc:159
arg
Definition: cmdline.cc:40
grpc::DefaultHealthCheckService
Definition: default_health_check_service.h:48
database
database
Definition: benchmark/.ycm_extra_conf.py:35
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc::DefaultHealthCheckService::ServiceData::Unused
bool Unused() const
Definition: default_health_check_service.h:265
grpc::ByteBuffer
A sequence of bytes.
Definition: include/grpcpp/impl/codegen/byte_buffer.h:61
grpc::Status::OK
static const Status & OK
An OK pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:113
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler::CheckCallHandler
CheckCallHandler(ServerCompletionQueue *cq, DefaultHealthCheckService *database, HealthCheckServiceImpl *service)
Definition: default_health_check_service.cc:281
grpc::DefaultHealthCheckService::GetServingStatus
ServingStatus GetServingStatus(const std::string &service_name) const
Definition: default_health_check_service.cc:86
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::cq_
std::unique_ptr< ServerCompletionQueue > cq_
Definition: default_health_check_service.h:233
grpc::DefaultHealthCheckService::shutdown_
bool shutdown_
Definition: default_health_check_service.h:284
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::CheckCallHandler::OnFinishDone
void OnFinishDone(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:329
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::~HealthCheckServiceImpl
~HealthCheckServiceImpl() override
Definition: default_health_check_service.cc:174
stdint.h
grpc::DefaultHealthCheckService::ServiceData::SetServingStatus
void SetServingStatus(ServingStatus status)
Definition: default_health_check_service.cc:132
request_
EchoRequest request_
Definition: client_callback_end2end_test.cc:724
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::WatchCallHandler
WatchCallHandler(ServerCompletionQueue *cq, DefaultHealthCheckService *database, HealthCheckServiceImpl *service)
Definition: default_health_check_service.cc:369
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::SendFinishLocked
void SendFinishLocked(std::shared_ptr< CallHandler > self, const Status &status)
Definition: default_health_check_service.cc:464
upb::Arena
Definition: upb.hpp:68
grpc_slice_from_copied_buffer
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Definition: slice/slice.cc:170
grpc::DefaultHealthCheckService::ServiceData::call_handlers_
std::set< std::shared_ptr< HealthCheckServiceImpl::CallHandler > > call_handlers_
Definition: default_health_check_service.h:272
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::SendFinish
void SendFinish(std::shared_ptr< CallHandler > self, const Status &status)
Definition: default_health_check_service.cc:456
grpc::DefaultHealthCheckService::SERVING
@ SERVING
Definition: default_health_check_service.h:50
upb_StringView
Definition: upb/upb/upb.h:72
grpc_health_v1_HealthCheckRequest_service
UPB_INLINE upb_StringView grpc_health_v1_HealthCheckRequest_service(const grpc_health_v1_HealthCheckRequest *msg)
Definition: health.upb.h:73
grpc::DefaultHealthCheckService::ServiceData::RemoveCallHandler
void RemoveCallHandler(const std::shared_ptr< HealthCheckServiceImpl::CallHandler > &handler)
Definition: default_health_check_service.cc:145
upb.hpp
client.handler
handler
Definition: examples/python/multiprocessing/client.py:87
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc_health_v1_HealthCheckResponse_new
UPB_INLINE grpc_health_v1_HealthCheckResponse * grpc_health_v1_HealthCheckResponse_new(upb_Arena *arena)
Definition: health.upb.h:83
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::OnDoneNotified
void OnDoneNotified(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:488
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
grpc.StatusCode.INVALID_ARGUMENT
tuple INVALID_ARGUMENT
Definition: src/python/grpcio/grpc/__init__.py:263
health.upb.h
MAX_SERVICE_NAME_LENGTH
#define MAX_SERVICE_NAME_LENGTH
Definition: default_health_check_service.cc:39
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
ok
bool ok
Definition: async_end2end_test.cc:197
grpc_health_v1_HealthCheckResponse_NOT_SERVING
@ grpc_health_v1_HealthCheckResponse_NOT_SERVING
Definition: health.upb.h:33
arg
struct arg arg
grpc::DefaultHealthCheckService::ServiceData::status_
ServingStatus status_
Definition: default_health_check_service.h:270
grpc_health_v1_HealthCheckRequest
struct grpc_health_v1_HealthCheckRequest grpc_health_v1_HealthCheckRequest
Definition: health.upb.h:25
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler::OnSendHealthDone
void OnSendHealthDone(std::shared_ptr< CallHandler > self, bool ok)
Definition: default_health_check_service.cc:439
grpc::DefaultHealthCheckService::Shutdown
void Shutdown() override
Definition: default_health_check_service.cc:73
grpc_health_v1_HealthCheckResponse_set_status
UPB_INLINE void grpc_health_v1_HealthCheckResponse_set_status(grpc_health_v1_HealthCheckResponse *msg, int32_t value)
Definition: health.upb.h:119
GPR_DEBUG
#define GPR_DEBUG
Definition: include/grpc/impl/codegen/log.h:55
grpc::DefaultHealthCheckService::HealthCheckServiceImpl
Definition: default_health_check_service.h:53
grpc::Service::AddMethod
void AddMethod(internal::RpcServiceMethod *method)
Definition: grpcpp/impl/codegen/service_type.h:147
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::Serve
static void Serve(void *arg)
Definition: default_health_check_service.cc:194
grpc::Slice
Definition: include/grpcpp/impl/codegen/slice.h:36
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
grpc.StatusCode.INTERNAL
tuple INTERNAL
Definition: src/python/grpcio/grpc/__init__.py:277
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::StartServingThread
void StartServingThread()
Definition: default_health_check_service.cc:184
grpc::internal::RpcMethod::SERVER_STREAMING
@ SERVER_STREAMING
Definition: grpcpp/impl/codegen/rpc_method.h:36
default_health_check_service.h
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::EncodeResponse
static bool EncodeResponse(ServingStatus status, ByteBuffer *response)
Definition: default_health_check_service.cc:233
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::WatchCallHandler
Definition: default_health_check_service.h:156
service_
std::unique_ptr< grpc::testing::TestServiceImpl > service_
Definition: end2end_binder_transport_test.cc:71
grpc::DefaultHealthCheckService::SetServingStatus
void SetServingStatus(const std::string &service_name, bool serving) override
Set or change the serving status of the given service_name.
Definition: default_health_check_service.cc:51
thread_
std::unique_ptr< std::thread > thread_
Definition: settings_timeout_test.cc:104


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:09