|
| 1 | +package io.grpc.examples; |
| 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 1.0.0)", |
| 22 | + comments = "Source: calculator.proto") |
| 23 | +public class CalculatorGrpc { |
| 24 | + |
| 25 | + private CalculatorGrpc() {} |
| 26 | + |
| 27 | + public static final String SERVICE_NAME = "Calculator"; |
| 28 | + |
| 29 | + // Static method descriptors that strictly reflect the proto. |
| 30 | + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") |
| 31 | + public static final io.grpc.MethodDescriptor<io.grpc.examples.CalculatorOuterClass.CalculatorRequest, |
| 32 | + io.grpc.examples.CalculatorOuterClass.CalculatorResponse> METHOD_CALCULATE = |
| 33 | + io.grpc.MethodDescriptor.create( |
| 34 | + io.grpc.MethodDescriptor.MethodType.UNARY, |
| 35 | + generateFullMethodName( |
| 36 | + "Calculator", "Calculate"), |
| 37 | + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.CalculatorOuterClass.CalculatorRequest.getDefaultInstance()), |
| 38 | + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.CalculatorOuterClass.CalculatorResponse.getDefaultInstance())); |
| 39 | + |
| 40 | + /** |
| 41 | + * Creates a new async stub that supports all call types for the service |
| 42 | + */ |
| 43 | + public static CalculatorStub newStub(io.grpc.Channel channel) { |
| 44 | + return new CalculatorStub(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 CalculatorBlockingStub newBlockingStub( |
| 51 | + io.grpc.Channel channel) { |
| 52 | + return new CalculatorBlockingStub(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 CalculatorFutureStub newFutureStub( |
| 59 | + io.grpc.Channel channel) { |
| 60 | + return new CalculatorFutureStub(channel); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + */ |
| 65 | + public static abstract class CalculatorImplBase implements io.grpc.BindableService { |
| 66 | + |
| 67 | + /** |
| 68 | + */ |
| 69 | + public void calculate(io.grpc.examples.CalculatorOuterClass.CalculatorRequest request, |
| 70 | + io.grpc.stub.StreamObserver<io.grpc.examples.CalculatorOuterClass.CalculatorResponse> responseObserver) { |
| 71 | + asyncUnimplementedUnaryCall(METHOD_CALCULATE, responseObserver); |
| 72 | + } |
| 73 | + |
| 74 | + @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { |
| 75 | + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) |
| 76 | + .addMethod( |
| 77 | + METHOD_CALCULATE, |
| 78 | + asyncUnaryCall( |
| 79 | + new MethodHandlers< |
| 80 | + io.grpc.examples.CalculatorOuterClass.CalculatorRequest, |
| 81 | + io.grpc.examples.CalculatorOuterClass.CalculatorResponse>( |
| 82 | + this, METHODID_CALCULATE))) |
| 83 | + .build(); |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + */ |
| 89 | + public static final class CalculatorStub extends io.grpc.stub.AbstractStub<CalculatorStub> { |
| 90 | + private CalculatorStub(io.grpc.Channel channel) { |
| 91 | + super(channel); |
| 92 | + } |
| 93 | + |
| 94 | + private CalculatorStub(io.grpc.Channel channel, |
| 95 | + io.grpc.CallOptions callOptions) { |
| 96 | + super(channel, callOptions); |
| 97 | + } |
| 98 | + |
| 99 | + @java.lang.Override |
| 100 | + protected CalculatorStub build(io.grpc.Channel channel, |
| 101 | + io.grpc.CallOptions callOptions) { |
| 102 | + return new CalculatorStub(channel, callOptions); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + */ |
| 107 | + public void calculate(io.grpc.examples.CalculatorOuterClass.CalculatorRequest request, |
| 108 | + io.grpc.stub.StreamObserver<io.grpc.examples.CalculatorOuterClass.CalculatorResponse> responseObserver) { |
| 109 | + asyncUnaryCall( |
| 110 | + getChannel().newCall(METHOD_CALCULATE, getCallOptions()), request, responseObserver); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + */ |
| 116 | + public static final class CalculatorBlockingStub extends io.grpc.stub.AbstractStub<CalculatorBlockingStub> { |
| 117 | + private CalculatorBlockingStub(io.grpc.Channel channel) { |
| 118 | + super(channel); |
| 119 | + } |
| 120 | + |
| 121 | + private CalculatorBlockingStub(io.grpc.Channel channel, |
| 122 | + io.grpc.CallOptions callOptions) { |
| 123 | + super(channel, callOptions); |
| 124 | + } |
| 125 | + |
| 126 | + @java.lang.Override |
| 127 | + protected CalculatorBlockingStub build(io.grpc.Channel channel, |
| 128 | + io.grpc.CallOptions callOptions) { |
| 129 | + return new CalculatorBlockingStub(channel, callOptions); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + */ |
| 134 | + public io.grpc.examples.CalculatorOuterClass.CalculatorResponse calculate(io.grpc.examples.CalculatorOuterClass.CalculatorRequest request) { |
| 135 | + return blockingUnaryCall( |
| 136 | + getChannel(), METHOD_CALCULATE, getCallOptions(), request); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + */ |
| 142 | + public static final class CalculatorFutureStub extends io.grpc.stub.AbstractStub<CalculatorFutureStub> { |
| 143 | + private CalculatorFutureStub(io.grpc.Channel channel) { |
| 144 | + super(channel); |
| 145 | + } |
| 146 | + |
| 147 | + private CalculatorFutureStub(io.grpc.Channel channel, |
| 148 | + io.grpc.CallOptions callOptions) { |
| 149 | + super(channel, callOptions); |
| 150 | + } |
| 151 | + |
| 152 | + @java.lang.Override |
| 153 | + protected CalculatorFutureStub build(io.grpc.Channel channel, |
| 154 | + io.grpc.CallOptions callOptions) { |
| 155 | + return new CalculatorFutureStub(channel, callOptions); |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + */ |
| 160 | + public com.google.common.util.concurrent.ListenableFuture<io.grpc.examples.CalculatorOuterClass.CalculatorResponse> calculate( |
| 161 | + io.grpc.examples.CalculatorOuterClass.CalculatorRequest request) { |
| 162 | + return futureUnaryCall( |
| 163 | + getChannel().newCall(METHOD_CALCULATE, getCallOptions()), request); |
| 164 | + } |
| 165 | + } |
| 166 | + |
| 167 | + private static final int METHODID_CALCULATE = 0; |
| 168 | + |
| 169 | + private static class MethodHandlers<Req, Resp> implements |
| 170 | + io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, |
| 171 | + io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>, |
| 172 | + io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>, |
| 173 | + io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> { |
| 174 | + private final CalculatorImplBase serviceImpl; |
| 175 | + private final int methodId; |
| 176 | + |
| 177 | + public MethodHandlers(CalculatorImplBase serviceImpl, int methodId) { |
| 178 | + this.serviceImpl = serviceImpl; |
| 179 | + this.methodId = methodId; |
| 180 | + } |
| 181 | + |
| 182 | + @java.lang.Override |
| 183 | + @java.lang.SuppressWarnings("unchecked") |
| 184 | + public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 185 | + switch (methodId) { |
| 186 | + case METHODID_CALCULATE: |
| 187 | + serviceImpl.calculate((io.grpc.examples.CalculatorOuterClass.CalculatorRequest) request, |
| 188 | + (io.grpc.stub.StreamObserver<io.grpc.examples.CalculatorOuterClass.CalculatorResponse>) responseObserver); |
| 189 | + break; |
| 190 | + default: |
| 191 | + throw new AssertionError(); |
| 192 | + } |
| 193 | + } |
| 194 | + |
| 195 | + @java.lang.Override |
| 196 | + @java.lang.SuppressWarnings("unchecked") |
| 197 | + public io.grpc.stub.StreamObserver<Req> invoke( |
| 198 | + io.grpc.stub.StreamObserver<Resp> responseObserver) { |
| 199 | + switch (methodId) { |
| 200 | + default: |
| 201 | + throw new AssertionError(); |
| 202 | + } |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + public static io.grpc.ServiceDescriptor getServiceDescriptor() { |
| 207 | + return new io.grpc.ServiceDescriptor(SERVICE_NAME, |
| 208 | + METHOD_CALCULATE); |
| 209 | + } |
| 210 | + |
| 211 | +} |
0 commit comments