mirror of https://github.com/grpc/grpc.git
commit
e98551723a
51 changed files with 474 additions and 176 deletions
@ -0,0 +1,70 @@ |
||||
GRPC Health Checking Protocol |
||||
================================ |
||||
|
||||
Health checks are used to probe whether the server is able to handle rpcs. The |
||||
client-to-server health checking can happen from point to point or via some |
||||
control system. A server may choose to reply “unhealthy” because it |
||||
is not ready to take requests, it is shutting down or some other reason. |
||||
The client can act accordingly if the response is not received within some time |
||||
window or the response says unhealthy in it. |
||||
|
||||
|
||||
A GRPC service is used as the health checking mechanism for both simple |
||||
client-to-server scenario and other control systems such as load-balancing. |
||||
Being a high |
||||
level service provides some benefits. Firstly, since it is a GRPC service |
||||
itself, doing a health check is in the same format as a normal rpc. Secondly, |
||||
it has rich semantics such as per-service health status. Thirdly, as a GRPC |
||||
service, it is able reuse all the existing billing, quota infrastructure, etc, |
||||
and thus the server has full control over the access of the health checking |
||||
service. |
||||
|
||||
## Service Definition |
||||
|
||||
The server should export a service defined in the following proto: |
||||
|
||||
``` |
||||
syntax = "proto3"; |
||||
|
||||
package grpc.health.v1alpha; |
||||
|
||||
message HealthCheckRequest { |
||||
string service = 1; |
||||
} |
||||
|
||||
message HealthCheckResponse { |
||||
enum ServingStatus { |
||||
UNKNOWN = 0; |
||||
SERVING = 1; |
||||
NOT_SERVING = 2; |
||||
} |
||||
ServingStatus status = 1; |
||||
} |
||||
|
||||
service Health { |
||||
rpc Check(HealthCheckRequest) returns (HealthCheckResponse); |
||||
} |
||||
``` |
||||
|
||||
A client can query the server’s health status by calling the `Check` method, and |
||||
a deadline should be set on the rpc. The client can optionally set the service |
||||
name it wants to query for health status. The suggested format of service name |
||||
is `package_names.ServiceName`, such as `grpc.health.v1alpha.Health`. |
||||
|
||||
The server should register all the services manually and set |
||||
the individual status, including an empty service name and its status. For each |
||||
request received, if the service name can be found in the registry, |
||||
a response must be sent back with an `OK` status and the status field should be |
||||
set to `SERVING` or `NOT_SERVING` accordingly. If the service name is not |
||||
registered, the server returns a `NOT_FOUND` GRPC status. |
||||
|
||||
The server should use an empty string as the key for server’s |
||||
overall health status, so that a client not interested in a specific service can |
||||
query the server's status with an empty request. The server can just do exact |
||||
matching of the service name without support of any kind of wildcard matching. |
||||
However, the service owner has the freedom to implement more complicated |
||||
matching semantics that both the client and server agree upon. |
||||
|
||||
A client can declare the server as unhealthy if the rpc is not finished after |
||||
some amount of time. The client should be able to handle the case where server |
||||
does not have the Health service. |
@ -1,77 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPCXX_AUTH_PROPERTY_ITERATOR_H |
||||
#define GRPCXX_AUTH_PROPERTY_ITERATOR_H |
||||
|
||||
#include <iterator> |
||||
#include <vector> |
||||
|
||||
#include <grpc++/config.h> |
||||
|
||||
struct grpc_auth_context; |
||||
struct grpc_auth_property; |
||||
struct grpc_auth_property_iterator; |
||||
|
||||
namespace grpc { |
||||
class SecureAuthContext; |
||||
|
||||
typedef std::pair<grpc::string, grpc::string> AuthProperty; |
||||
|
||||
class AuthPropertyIterator |
||||
: public std::iterator<std::input_iterator_tag, const AuthProperty> { |
||||
public: |
||||
~AuthPropertyIterator(); |
||||
AuthPropertyIterator& operator++(); |
||||
AuthPropertyIterator operator++(int); |
||||
bool operator==(const AuthPropertyIterator& rhs) const; |
||||
bool operator!=(const AuthPropertyIterator& rhs) const; |
||||
const AuthProperty operator*(); |
||||
|
||||
protected: |
||||
AuthPropertyIterator(); |
||||
AuthPropertyIterator(const grpc_auth_property* property, |
||||
const grpc_auth_property_iterator* iter); |
||||
private: |
||||
friend class SecureAuthContext; |
||||
const grpc_auth_property* property_; |
||||
// The following items form a grpc_auth_property_iterator.
|
||||
const grpc_auth_context* ctx_; |
||||
size_t index_; |
||||
const char* name_; |
||||
}; |
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_AUTH_PROPERTY_ITERATOR_H
|
||||
|
@ -0,0 +1,2 @@ |
||||
|
||||
SandCastle project files to generate HTML reference documentation. |
@ -0,0 +1,30 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
|
Loading…
Reference in new issue