services: sync health.proto from grpc-proto repo (#4904)

This commit is contained in:
Kun Zhang 2018-10-03 16:24:09 -07:00 committed by GitHub
parent 6b7fa40378
commit 31328652d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 181 additions and 7 deletions

View File

@ -59,6 +59,38 @@ public final class HealthGrpc {
return getCheckMethod; return getCheckMethod;
} }
private static volatile io.grpc.MethodDescriptor<io.grpc.health.v1.HealthCheckRequest,
io.grpc.health.v1.HealthCheckResponse> getWatchMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "Watch",
requestType = io.grpc.health.v1.HealthCheckRequest.class,
responseType = io.grpc.health.v1.HealthCheckResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
public static io.grpc.MethodDescriptor<io.grpc.health.v1.HealthCheckRequest,
io.grpc.health.v1.HealthCheckResponse> getWatchMethod() {
io.grpc.MethodDescriptor<io.grpc.health.v1.HealthCheckRequest, io.grpc.health.v1.HealthCheckResponse> getWatchMethod;
if ((getWatchMethod = HealthGrpc.getWatchMethod) == null) {
synchronized (HealthGrpc.class) {
if ((getWatchMethod = HealthGrpc.getWatchMethod) == null) {
HealthGrpc.getWatchMethod = getWatchMethod =
io.grpc.MethodDescriptor.<io.grpc.health.v1.HealthCheckRequest, io.grpc.health.v1.HealthCheckResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(
"grpc.health.v1.Health", "Watch"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.grpc.health.v1.HealthCheckRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.grpc.health.v1.HealthCheckResponse.getDefaultInstance()))
.setSchemaDescriptor(new HealthMethodDescriptorSupplier("Watch"))
.build();
}
}
}
return getWatchMethod;
}
/** /**
* Creates a new async stub that supports all call types for the service * Creates a new async stub that supports all call types for the service
*/ */
@ -87,12 +119,38 @@ public final class HealthGrpc {
public static abstract class HealthImplBase implements io.grpc.BindableService { public static abstract class HealthImplBase implements io.grpc.BindableService {
/** /**
* <pre>
* If the requested service is unknown, the call will fail with status
* NOT_FOUND.
* </pre>
*/ */
public void check(io.grpc.health.v1.HealthCheckRequest request, public void check(io.grpc.health.v1.HealthCheckRequest request,
io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) { io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) {
asyncUnimplementedUnaryCall(getCheckMethod(), responseObserver); asyncUnimplementedUnaryCall(getCheckMethod(), responseObserver);
} }
/**
* <pre>
* 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.
* </pre>
*/
public void watch(io.grpc.health.v1.HealthCheckRequest request,
io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) {
asyncUnimplementedUnaryCall(getWatchMethod(), responseObserver);
}
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod( .addMethod(
@ -102,6 +160,13 @@ public final class HealthGrpc {
io.grpc.health.v1.HealthCheckRequest, io.grpc.health.v1.HealthCheckRequest,
io.grpc.health.v1.HealthCheckResponse>( io.grpc.health.v1.HealthCheckResponse>(
this, METHODID_CHECK))) this, METHODID_CHECK)))
.addMethod(
getWatchMethod(),
asyncServerStreamingCall(
new MethodHandlers<
io.grpc.health.v1.HealthCheckRequest,
io.grpc.health.v1.HealthCheckResponse>(
this, METHODID_WATCH)))
.build(); .build();
} }
} }
@ -125,12 +190,39 @@ public final class HealthGrpc {
} }
/** /**
* <pre>
* If the requested service is unknown, the call will fail with status
* NOT_FOUND.
* </pre>
*/ */
public void check(io.grpc.health.v1.HealthCheckRequest request, public void check(io.grpc.health.v1.HealthCheckRequest request,
io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) { io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) {
asyncUnaryCall( asyncUnaryCall(
getChannel().newCall(getCheckMethod(), getCallOptions()), request, responseObserver); getChannel().newCall(getCheckMethod(), getCallOptions()), request, responseObserver);
} }
/**
* <pre>
* 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.
* </pre>
*/
public void watch(io.grpc.health.v1.HealthCheckRequest request,
io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse> responseObserver) {
asyncServerStreamingCall(
getChannel().newCall(getWatchMethod(), getCallOptions()), request, responseObserver);
}
} }
/** /**
@ -152,11 +244,38 @@ public final class HealthGrpc {
} }
/** /**
* <pre>
* If the requested service is unknown, the call will fail with status
* NOT_FOUND.
* </pre>
*/ */
public io.grpc.health.v1.HealthCheckResponse check(io.grpc.health.v1.HealthCheckRequest request) { public io.grpc.health.v1.HealthCheckResponse check(io.grpc.health.v1.HealthCheckRequest request) {
return blockingUnaryCall( return blockingUnaryCall(
getChannel(), getCheckMethod(), getCallOptions(), request); getChannel(), getCheckMethod(), getCallOptions(), request);
} }
/**
* <pre>
* 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.
* </pre>
*/
public java.util.Iterator<io.grpc.health.v1.HealthCheckResponse> watch(
io.grpc.health.v1.HealthCheckRequest request) {
return blockingServerStreamingCall(
getChannel(), getWatchMethod(), getCallOptions(), request);
}
} }
/** /**
@ -178,6 +297,10 @@ public final class HealthGrpc {
} }
/** /**
* <pre>
* If the requested service is unknown, the call will fail with status
* NOT_FOUND.
* </pre>
*/ */
public com.google.common.util.concurrent.ListenableFuture<io.grpc.health.v1.HealthCheckResponse> check( public com.google.common.util.concurrent.ListenableFuture<io.grpc.health.v1.HealthCheckResponse> check(
io.grpc.health.v1.HealthCheckRequest request) { io.grpc.health.v1.HealthCheckRequest request) {
@ -187,6 +310,7 @@ public final class HealthGrpc {
} }
private static final int METHODID_CHECK = 0; private static final int METHODID_CHECK = 0;
private static final int METHODID_WATCH = 1;
private static final class MethodHandlers<Req, Resp> implements private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
@ -209,6 +333,10 @@ public final class HealthGrpc {
serviceImpl.check((io.grpc.health.v1.HealthCheckRequest) request, serviceImpl.check((io.grpc.health.v1.HealthCheckRequest) request,
(io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse>) responseObserver); (io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse>) responseObserver);
break; break;
case METHODID_WATCH:
serviceImpl.watch((io.grpc.health.v1.HealthCheckRequest) request,
(io.grpc.stub.StreamObserver<io.grpc.health.v1.HealthCheckResponse>) responseObserver);
break;
default: default:
throw new AssertionError(); throw new AssertionError();
} }
@ -271,6 +399,7 @@ public final class HealthGrpc {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new HealthFileDescriptorSupplier()) .setSchemaDescriptor(new HealthFileDescriptorSupplier())
.addMethod(getCheckMethod()) .addMethod(getCheckMethod())
.addMethod(getWatchMethod())
.build(); .build();
} }
} }

View File

@ -97,6 +97,14 @@ private static final long serialVersionUID = 0L;
* <code>NOT_SERVING = 2;</code> * <code>NOT_SERVING = 2;</code>
*/ */
NOT_SERVING(2), NOT_SERVING(2),
/**
* <pre>
* Used only by the Watch method.
* </pre>
*
* <code>SERVICE_UNKNOWN = 3;</code>
*/
SERVICE_UNKNOWN(3),
UNRECOGNIZED(-1), UNRECOGNIZED(-1),
; ;
@ -112,6 +120,14 @@ private static final long serialVersionUID = 0L;
* <code>NOT_SERVING = 2;</code> * <code>NOT_SERVING = 2;</code>
*/ */
public static final int NOT_SERVING_VALUE = 2; public static final int NOT_SERVING_VALUE = 2;
/**
* <pre>
* Used only by the Watch method.
* </pre>
*
* <code>SERVICE_UNKNOWN = 3;</code>
*/
public static final int SERVICE_UNKNOWN_VALUE = 3;
public final int getNumber() { public final int getNumber() {
@ -135,6 +151,7 @@ private static final long serialVersionUID = 0L;
case 0: return UNKNOWN; case 0: return UNKNOWN;
case 1: return SERVING; case 1: return SERVING;
case 2: return NOT_SERVING; case 2: return NOT_SERVING;
case 3: return SERVICE_UNKNOWN;
default: return null; default: return null;
} }
} }

View File

@ -35,14 +35,18 @@ public final class HealthProto {
java.lang.String[] descriptorData = { java.lang.String[] descriptorData = {
"\n\033grpc/health/v1/health.proto\022\016grpc.heal" + "\n\033grpc/health/v1/health.proto\022\016grpc.heal" +
"th.v1\"%\n\022HealthCheckRequest\022\017\n\007service\030\001" + "th.v1\"%\n\022HealthCheckRequest\022\017\n\007service\030\001" +
" \001(\t\"\224\001\n\023HealthCheckResponse\022A\n\006status\030\001" + " \001(\t\"\251\001\n\023HealthCheckResponse\022A\n\006status\030\001" +
" \001(\01621.grpc.health.v1.HealthCheckRespons" + " \001(\01621.grpc.health.v1.HealthCheckRespons" +
"e.ServingStatus\":\n\rServingStatus\022\013\n\007UNKN" + "e.ServingStatus\"O\n\rServingStatus\022\013\n\007UNKN" +
"OWN\020\000\022\013\n\007SERVING\020\001\022\017\n\013NOT_SERVING\020\0022Z\n\006H" + "OWN\020\000\022\013\n\007SERVING\020\001\022\017\n\013NOT_SERVING\020\002\022\023\n\017S" +
"ealth\022P\n\005Check\022\".grpc.health.v1.HealthCh" + "ERVICE_UNKNOWN\020\0032\256\001\n\006Health\022P\n\005Check\022\".g" +
"eckRequest\032#.grpc.health.v1.HealthCheckR" + "rpc.health.v1.HealthCheckRequest\032#.grpc." +
"esponseB3\n\021io.grpc.health.v1B\013HealthProt" + "health.v1.HealthCheckResponse\022R\n\005Watch\022\"" +
"oP\001\252\002\016Grpc.Health.V1b\006proto3" ".grpc.health.v1.HealthCheckRequest\032#.grp" +
"c.health.v1.HealthCheckResponse0\001Ba\n\021io." +
"grpc.health.v1B\013HealthProtoP\001Z,google.go" +
"lang.org/grpc/health/grpc_health_v1\252\002\016Gr" +
"pc.Health.V1b\006proto3"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {

View File

@ -12,11 +12,15 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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"; syntax = "proto3";
package grpc.health.v1; package grpc.health.v1;
option csharp_namespace = "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_multiple_files = true;
option java_outer_classname = "HealthProto"; option java_outer_classname = "HealthProto";
option java_package = "io.grpc.health.v1"; option java_package = "io.grpc.health.v1";
@ -30,10 +34,30 @@ message HealthCheckResponse {
UNKNOWN = 0; UNKNOWN = 0;
SERVING = 1; SERVING = 1;
NOT_SERVING = 2; NOT_SERVING = 2;
SERVICE_UNKNOWN = 3; // Used only by the Watch method.
} }
ServingStatus status = 1; ServingStatus status = 1;
} }
service Health { service Health {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
rpc Check(HealthCheckRequest) returns (HealthCheckResponse); 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);
} }