Skip to content

Commit ee964c2

Browse files
committed
health check service
1 parent d9d4d8b commit ee964c2

File tree

11 files changed

+1743
-0
lines changed

11 files changed

+1743
-0
lines changed

services/build.gradle

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Add dependency on the protobuf plugin
2+
buildscript {
3+
repositories {
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath libraries.protobuf_plugin
8+
}
9+
}
10+
11+
plugins {
12+
id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0"
13+
}
14+
15+
description = "gRPC: Services"
16+
17+
dependencies {
18+
compile project(':grpc-protobuf'),
19+
project(':grpc-stub')
20+
}
21+
22+
configureProtoCompilation()
23+
24+
// Configure the animal sniffer plugin
25+
animalsniffer {
26+
signature = "org.codehaus.mojo.signature:java16:+@signature"
27+
}
28+
29+
// Let intellij projects refer to generated code
30+
idea {
31+
module {
32+
sourceDirs += file("${projectDir}/src/generated/main/java");
33+
sourceDirs += file("${projectDir}/src/generated/main/grpc");
34+
}
35+
}
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
package io.grpc.services.health;
2+
3+
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
4+
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
5+
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
7+
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
8+
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
9+
import static io.grpc.stub.ClientCalls.futureUnaryCall;
10+
import static io.grpc.MethodDescriptor.generateFullMethodName;
11+
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
12+
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
13+
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
14+
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
15+
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
16+
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
17+
18+
/**
19+
*/
20+
@javax.annotation.Generated(
21+
value = "by gRPC proto compiler (version 0.15.0-SNAPSHOT)",
22+
comments = "Source: health.proto")
23+
public class HealthGrpc {
24+
25+
private HealthGrpc() {}
26+
27+
public static final String SERVICE_NAME = "grpc.health.v1.Health";
28+
29+
// Static method descriptors that strictly reflect the proto.
30+
@io.grpc.ExperimentalApi
31+
public static final io.grpc.MethodDescriptor<io.grpc.services.health.HealthOuterClass.HealthCheckRequest,
32+
io.grpc.services.health.HealthOuterClass.HealthCheckResponse> METHOD_CHECK =
33+
io.grpc.MethodDescriptor.create(
34+
io.grpc.MethodDescriptor.MethodType.UNARY,
35+
generateFullMethodName(
36+
"grpc.health.v1.Health", "Check"),
37+
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.services.health.HealthOuterClass.HealthCheckRequest.getDefaultInstance()),
38+
io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.services.health.HealthOuterClass.HealthCheckResponse.getDefaultInstance()));
39+
40+
/**
41+
* Creates a new async stub that supports all call types for the service
42+
*/
43+
public static HealthStub newStub(io.grpc.Channel channel) {
44+
return new HealthStub(channel);
45+
}
46+
47+
/**
48+
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
49+
*/
50+
public static HealthBlockingStub newBlockingStub(
51+
io.grpc.Channel channel) {
52+
return new HealthBlockingStub(channel);
53+
}
54+
55+
/**
56+
* Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service
57+
*/
58+
public static HealthFutureStub newFutureStub(
59+
io.grpc.Channel channel) {
60+
return new HealthFutureStub(channel);
61+
}
62+
63+
/**
64+
*/
65+
public static interface Health {
66+
67+
/**
68+
*/
69+
public void check(io.grpc.services.health.HealthOuterClass.HealthCheckRequest request,
70+
io.grpc.stub.StreamObserver<io.grpc.services.health.HealthOuterClass.HealthCheckResponse> responseObserver);
71+
}
72+
73+
@io.grpc.ExperimentalApi
74+
public static abstract class AbstractHealth implements Health, io.grpc.BindableService {
75+
76+
@java.lang.Override
77+
public void check(io.grpc.services.health.HealthOuterClass.HealthCheckRequest request,
78+
io.grpc.stub.StreamObserver<io.grpc.services.health.HealthOuterClass.HealthCheckResponse> responseObserver) {
79+
asyncUnimplementedUnaryCall(METHOD_CHECK, responseObserver);
80+
}
81+
82+
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
83+
return HealthGrpc.bindService(this);
84+
}
85+
}
86+
87+
/**
88+
*/
89+
public static interface HealthBlockingClient {
90+
91+
/**
92+
*/
93+
public io.grpc.services.health.HealthOuterClass.HealthCheckResponse check(io.grpc.services.health.HealthOuterClass.HealthCheckRequest request);
94+
}
95+
96+
/**
97+
*/
98+
public static interface HealthFutureClient {
99+
100+
/**
101+
*/
102+
public com.google.common.util.concurrent.ListenableFuture<io.grpc.services.health.HealthOuterClass.HealthCheckResponse> check(
103+
io.grpc.services.health.HealthOuterClass.HealthCheckRequest request);
104+
}
105+
106+
public static class HealthStub extends io.grpc.stub.AbstractStub<HealthStub>
107+
implements Health {
108+
private HealthStub(io.grpc.Channel channel) {
109+
super(channel);
110+
}
111+
112+
private HealthStub(io.grpc.Channel channel,
113+
io.grpc.CallOptions callOptions) {
114+
super(channel, callOptions);
115+
}
116+
117+
@java.lang.Override
118+
protected HealthStub build(io.grpc.Channel channel,
119+
io.grpc.CallOptions callOptions) {
120+
return new HealthStub(channel, callOptions);
121+
}
122+
123+
@java.lang.Override
124+
public void check(io.grpc.services.health.HealthOuterClass.HealthCheckRequest request,
125+
io.grpc.stub.StreamObserver<io.grpc.services.health.HealthOuterClass.HealthCheckResponse> responseObserver) {
126+
asyncUnaryCall(
127+
getChannel().newCall(METHOD_CHECK, getCallOptions()), request, responseObserver);
128+
}
129+
}
130+
131+
public static class HealthBlockingStub extends io.grpc.stub.AbstractStub<HealthBlockingStub>
132+
implements HealthBlockingClient {
133+
private HealthBlockingStub(io.grpc.Channel channel) {
134+
super(channel);
135+
}
136+
137+
private HealthBlockingStub(io.grpc.Channel channel,
138+
io.grpc.CallOptions callOptions) {
139+
super(channel, callOptions);
140+
}
141+
142+
@java.lang.Override
143+
protected HealthBlockingStub build(io.grpc.Channel channel,
144+
io.grpc.CallOptions callOptions) {
145+
return new HealthBlockingStub(channel, callOptions);
146+
}
147+
148+
@java.lang.Override
149+
public io.grpc.services.health.HealthOuterClass.HealthCheckResponse check(io.grpc.services.health.HealthOuterClass.HealthCheckRequest request) {
150+
return blockingUnaryCall(
151+
getChannel(), METHOD_CHECK, getCallOptions(), request);
152+
}
153+
}
154+
155+
public static class HealthFutureStub extends io.grpc.stub.AbstractStub<HealthFutureStub>
156+
implements HealthFutureClient {
157+
private HealthFutureStub(io.grpc.Channel channel) {
158+
super(channel);
159+
}
160+
161+
private HealthFutureStub(io.grpc.Channel channel,
162+
io.grpc.CallOptions callOptions) {
163+
super(channel, callOptions);
164+
}
165+
166+
@java.lang.Override
167+
protected HealthFutureStub build(io.grpc.Channel channel,
168+
io.grpc.CallOptions callOptions) {
169+
return new HealthFutureStub(channel, callOptions);
170+
}
171+
172+
@java.lang.Override
173+
public com.google.common.util.concurrent.ListenableFuture<io.grpc.services.health.HealthOuterClass.HealthCheckResponse> check(
174+
io.grpc.services.health.HealthOuterClass.HealthCheckRequest request) {
175+
return futureUnaryCall(
176+
getChannel().newCall(METHOD_CHECK, getCallOptions()), request);
177+
}
178+
}
179+
180+
private static final int METHODID_CHECK = 0;
181+
182+
private static class MethodHandlers<Req, Resp> implements
183+
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
184+
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
185+
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
186+
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
187+
private final Health serviceImpl;
188+
private final int methodId;
189+
190+
public MethodHandlers(Health serviceImpl, int methodId) {
191+
this.serviceImpl = serviceImpl;
192+
this.methodId = methodId;
193+
}
194+
195+
@java.lang.Override
196+
@java.lang.SuppressWarnings("unchecked")
197+
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
198+
switch (methodId) {
199+
case METHODID_CHECK:
200+
serviceImpl.check((io.grpc.services.health.HealthOuterClass.HealthCheckRequest) request,
201+
(io.grpc.stub.StreamObserver<io.grpc.services.health.HealthOuterClass.HealthCheckResponse>) responseObserver);
202+
break;
203+
default:
204+
throw new AssertionError();
205+
}
206+
}
207+
208+
@java.lang.Override
209+
@java.lang.SuppressWarnings("unchecked")
210+
public io.grpc.stub.StreamObserver<Req> invoke(
211+
io.grpc.stub.StreamObserver<Resp> responseObserver) {
212+
switch (methodId) {
213+
default:
214+
throw new AssertionError();
215+
}
216+
}
217+
}
218+
219+
public static io.grpc.ServerServiceDefinition bindService(
220+
final Health serviceImpl) {
221+
return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME)
222+
.addMethod(
223+
METHOD_CHECK,
224+
asyncUnaryCall(
225+
new MethodHandlers<
226+
io.grpc.services.health.HealthOuterClass.HealthCheckRequest,
227+
io.grpc.services.health.HealthOuterClass.HealthCheckResponse>(
228+
serviceImpl, METHODID_CHECK)))
229+
.build();
230+
}
231+
}

0 commit comments

Comments
 (0)