1 /* 2 * Copyright 2020 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.cloud.retail.v2; 17 18 import static io.grpc.MethodDescriptor.generateFullMethodName; 19 20 /** 21 * 22 * 23 * <pre> 24 * Service for making recommendation prediction. 25 * </pre> 26 */ 27 @javax.annotation.Generated( 28 value = "by gRPC proto compiler", 29 comments = "Source: google/cloud/retail/v2/prediction_service.proto") 30 @io.grpc.stub.annotations.GrpcGenerated 31 public final class PredictionServiceGrpc { 32 PredictionServiceGrpc()33 private PredictionServiceGrpc() {} 34 35 public static final String SERVICE_NAME = "google.cloud.retail.v2.PredictionService"; 36 37 // Static method descriptors that strictly reflect the proto. 38 private static volatile io.grpc.MethodDescriptor< 39 com.google.cloud.retail.v2.PredictRequest, com.google.cloud.retail.v2.PredictResponse> 40 getPredictMethod; 41 42 @io.grpc.stub.annotations.RpcMethod( 43 fullMethodName = SERVICE_NAME + '/' + "Predict", 44 requestType = com.google.cloud.retail.v2.PredictRequest.class, 45 responseType = com.google.cloud.retail.v2.PredictResponse.class, 46 methodType = io.grpc.MethodDescriptor.MethodType.UNARY) 47 public static io.grpc.MethodDescriptor< 48 com.google.cloud.retail.v2.PredictRequest, com.google.cloud.retail.v2.PredictResponse> getPredictMethod()49 getPredictMethod() { 50 io.grpc.MethodDescriptor< 51 com.google.cloud.retail.v2.PredictRequest, com.google.cloud.retail.v2.PredictResponse> 52 getPredictMethod; 53 if ((getPredictMethod = PredictionServiceGrpc.getPredictMethod) == null) { 54 synchronized (PredictionServiceGrpc.class) { 55 if ((getPredictMethod = PredictionServiceGrpc.getPredictMethod) == null) { 56 PredictionServiceGrpc.getPredictMethod = 57 getPredictMethod = 58 io.grpc.MethodDescriptor 59 .<com.google.cloud.retail.v2.PredictRequest, 60 com.google.cloud.retail.v2.PredictResponse> 61 newBuilder() 62 .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 63 .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Predict")) 64 .setSampledToLocalTracing(true) 65 .setRequestMarshaller( 66 io.grpc.protobuf.ProtoUtils.marshaller( 67 com.google.cloud.retail.v2.PredictRequest.getDefaultInstance())) 68 .setResponseMarshaller( 69 io.grpc.protobuf.ProtoUtils.marshaller( 70 com.google.cloud.retail.v2.PredictResponse.getDefaultInstance())) 71 .setSchemaDescriptor(new PredictionServiceMethodDescriptorSupplier("Predict")) 72 .build(); 73 } 74 } 75 } 76 return getPredictMethod; 77 } 78 79 /** Creates a new async stub that supports all call types for the service */ newStub(io.grpc.Channel channel)80 public static PredictionServiceStub newStub(io.grpc.Channel channel) { 81 io.grpc.stub.AbstractStub.StubFactory<PredictionServiceStub> factory = 82 new io.grpc.stub.AbstractStub.StubFactory<PredictionServiceStub>() { 83 @java.lang.Override 84 public PredictionServiceStub newStub( 85 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 86 return new PredictionServiceStub(channel, callOptions); 87 } 88 }; 89 return PredictionServiceStub.newStub(factory, channel); 90 } 91 92 /** 93 * Creates a new blocking-style stub that supports unary and streaming output calls on the service 94 */ newBlockingStub(io.grpc.Channel channel)95 public static PredictionServiceBlockingStub newBlockingStub(io.grpc.Channel channel) { 96 io.grpc.stub.AbstractStub.StubFactory<PredictionServiceBlockingStub> factory = 97 new io.grpc.stub.AbstractStub.StubFactory<PredictionServiceBlockingStub>() { 98 @java.lang.Override 99 public PredictionServiceBlockingStub newStub( 100 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 101 return new PredictionServiceBlockingStub(channel, callOptions); 102 } 103 }; 104 return PredictionServiceBlockingStub.newStub(factory, channel); 105 } 106 107 /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ newFutureStub(io.grpc.Channel channel)108 public static PredictionServiceFutureStub newFutureStub(io.grpc.Channel channel) { 109 io.grpc.stub.AbstractStub.StubFactory<PredictionServiceFutureStub> factory = 110 new io.grpc.stub.AbstractStub.StubFactory<PredictionServiceFutureStub>() { 111 @java.lang.Override 112 public PredictionServiceFutureStub newStub( 113 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 114 return new PredictionServiceFutureStub(channel, callOptions); 115 } 116 }; 117 return PredictionServiceFutureStub.newStub(factory, channel); 118 } 119 120 /** 121 * 122 * 123 * <pre> 124 * Service for making recommendation prediction. 125 * </pre> 126 */ 127 public interface AsyncService { 128 129 /** 130 * 131 * 132 * <pre> 133 * Makes a recommendation prediction. 134 * </pre> 135 */ predict( com.google.cloud.retail.v2.PredictRequest request, io.grpc.stub.StreamObserver<com.google.cloud.retail.v2.PredictResponse> responseObserver)136 default void predict( 137 com.google.cloud.retail.v2.PredictRequest request, 138 io.grpc.stub.StreamObserver<com.google.cloud.retail.v2.PredictResponse> responseObserver) { 139 io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getPredictMethod(), responseObserver); 140 } 141 } 142 143 /** 144 * Base class for the server implementation of the service PredictionService. 145 * 146 * <pre> 147 * Service for making recommendation prediction. 148 * </pre> 149 */ 150 public abstract static class PredictionServiceImplBase 151 implements io.grpc.BindableService, AsyncService { 152 153 @java.lang.Override bindService()154 public final io.grpc.ServerServiceDefinition bindService() { 155 return PredictionServiceGrpc.bindService(this); 156 } 157 } 158 159 /** 160 * A stub to allow clients to do asynchronous rpc calls to service PredictionService. 161 * 162 * <pre> 163 * Service for making recommendation prediction. 164 * </pre> 165 */ 166 public static final class PredictionServiceStub 167 extends io.grpc.stub.AbstractAsyncStub<PredictionServiceStub> { PredictionServiceStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions)168 private PredictionServiceStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 169 super(channel, callOptions); 170 } 171 172 @java.lang.Override build( io.grpc.Channel channel, io.grpc.CallOptions callOptions)173 protected PredictionServiceStub build( 174 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 175 return new PredictionServiceStub(channel, callOptions); 176 } 177 178 /** 179 * 180 * 181 * <pre> 182 * Makes a recommendation prediction. 183 * </pre> 184 */ predict( com.google.cloud.retail.v2.PredictRequest request, io.grpc.stub.StreamObserver<com.google.cloud.retail.v2.PredictResponse> responseObserver)185 public void predict( 186 com.google.cloud.retail.v2.PredictRequest request, 187 io.grpc.stub.StreamObserver<com.google.cloud.retail.v2.PredictResponse> responseObserver) { 188 io.grpc.stub.ClientCalls.asyncUnaryCall( 189 getChannel().newCall(getPredictMethod(), getCallOptions()), request, responseObserver); 190 } 191 } 192 193 /** 194 * A stub to allow clients to do synchronous rpc calls to service PredictionService. 195 * 196 * <pre> 197 * Service for making recommendation prediction. 198 * </pre> 199 */ 200 public static final class PredictionServiceBlockingStub 201 extends io.grpc.stub.AbstractBlockingStub<PredictionServiceBlockingStub> { PredictionServiceBlockingStub( io.grpc.Channel channel, io.grpc.CallOptions callOptions)202 private PredictionServiceBlockingStub( 203 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 204 super(channel, callOptions); 205 } 206 207 @java.lang.Override build( io.grpc.Channel channel, io.grpc.CallOptions callOptions)208 protected PredictionServiceBlockingStub build( 209 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 210 return new PredictionServiceBlockingStub(channel, callOptions); 211 } 212 213 /** 214 * 215 * 216 * <pre> 217 * Makes a recommendation prediction. 218 * </pre> 219 */ predict( com.google.cloud.retail.v2.PredictRequest request)220 public com.google.cloud.retail.v2.PredictResponse predict( 221 com.google.cloud.retail.v2.PredictRequest request) { 222 return io.grpc.stub.ClientCalls.blockingUnaryCall( 223 getChannel(), getPredictMethod(), getCallOptions(), request); 224 } 225 } 226 227 /** 228 * A stub to allow clients to do ListenableFuture-style rpc calls to service PredictionService. 229 * 230 * <pre> 231 * Service for making recommendation prediction. 232 * </pre> 233 */ 234 public static final class PredictionServiceFutureStub 235 extends io.grpc.stub.AbstractFutureStub<PredictionServiceFutureStub> { PredictionServiceFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions)236 private PredictionServiceFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 237 super(channel, callOptions); 238 } 239 240 @java.lang.Override build( io.grpc.Channel channel, io.grpc.CallOptions callOptions)241 protected PredictionServiceFutureStub build( 242 io.grpc.Channel channel, io.grpc.CallOptions callOptions) { 243 return new PredictionServiceFutureStub(channel, callOptions); 244 } 245 246 /** 247 * 248 * 249 * <pre> 250 * Makes a recommendation prediction. 251 * </pre> 252 */ 253 public com.google.common.util.concurrent.ListenableFuture< 254 com.google.cloud.retail.v2.PredictResponse> predict(com.google.cloud.retail.v2.PredictRequest request)255 predict(com.google.cloud.retail.v2.PredictRequest request) { 256 return io.grpc.stub.ClientCalls.futureUnaryCall( 257 getChannel().newCall(getPredictMethod(), getCallOptions()), request); 258 } 259 } 260 261 private static final int METHODID_PREDICT = 0; 262 263 private static final class MethodHandlers<Req, Resp> 264 implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, 265 io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>, 266 io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>, 267 io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> { 268 private final AsyncService serviceImpl; 269 private final int methodId; 270 MethodHandlers(AsyncService serviceImpl, int methodId)271 MethodHandlers(AsyncService serviceImpl, int methodId) { 272 this.serviceImpl = serviceImpl; 273 this.methodId = methodId; 274 } 275 276 @java.lang.Override 277 @java.lang.SuppressWarnings("unchecked") invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver)278 public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) { 279 switch (methodId) { 280 case METHODID_PREDICT: 281 serviceImpl.predict( 282 (com.google.cloud.retail.v2.PredictRequest) request, 283 (io.grpc.stub.StreamObserver<com.google.cloud.retail.v2.PredictResponse>) 284 responseObserver); 285 break; 286 default: 287 throw new AssertionError(); 288 } 289 } 290 291 @java.lang.Override 292 @java.lang.SuppressWarnings("unchecked") invoke( io.grpc.stub.StreamObserver<Resp> responseObserver)293 public io.grpc.stub.StreamObserver<Req> invoke( 294 io.grpc.stub.StreamObserver<Resp> responseObserver) { 295 switch (methodId) { 296 default: 297 throw new AssertionError(); 298 } 299 } 300 } 301 bindService(AsyncService service)302 public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { 303 return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) 304 .addMethod( 305 getPredictMethod(), 306 io.grpc.stub.ServerCalls.asyncUnaryCall( 307 new MethodHandlers< 308 com.google.cloud.retail.v2.PredictRequest, 309 com.google.cloud.retail.v2.PredictResponse>(service, METHODID_PREDICT))) 310 .build(); 311 } 312 313 private abstract static class PredictionServiceBaseDescriptorSupplier 314 implements io.grpc.protobuf.ProtoFileDescriptorSupplier, 315 io.grpc.protobuf.ProtoServiceDescriptorSupplier { PredictionServiceBaseDescriptorSupplier()316 PredictionServiceBaseDescriptorSupplier() {} 317 318 @java.lang.Override getFileDescriptor()319 public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { 320 return com.google.cloud.retail.v2.PredictionServiceProto.getDescriptor(); 321 } 322 323 @java.lang.Override getServiceDescriptor()324 public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { 325 return getFileDescriptor().findServiceByName("PredictionService"); 326 } 327 } 328 329 private static final class PredictionServiceFileDescriptorSupplier 330 extends PredictionServiceBaseDescriptorSupplier { PredictionServiceFileDescriptorSupplier()331 PredictionServiceFileDescriptorSupplier() {} 332 } 333 334 private static final class PredictionServiceMethodDescriptorSupplier 335 extends PredictionServiceBaseDescriptorSupplier 336 implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { 337 private final String methodName; 338 PredictionServiceMethodDescriptorSupplier(String methodName)339 PredictionServiceMethodDescriptorSupplier(String methodName) { 340 this.methodName = methodName; 341 } 342 343 @java.lang.Override getMethodDescriptor()344 public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { 345 return getServiceDescriptor().findMethodByName(methodName); 346 } 347 } 348 349 private static volatile io.grpc.ServiceDescriptor serviceDescriptor; 350 getServiceDescriptor()351 public static io.grpc.ServiceDescriptor getServiceDescriptor() { 352 io.grpc.ServiceDescriptor result = serviceDescriptor; 353 if (result == null) { 354 synchronized (PredictionServiceGrpc.class) { 355 result = serviceDescriptor; 356 if (result == null) { 357 serviceDescriptor = 358 result = 359 io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) 360 .setSchemaDescriptor(new PredictionServiceFileDescriptorSupplier()) 361 .addMethod(getPredictMethod()) 362 .build(); 363 } 364 } 365 } 366 return result; 367 } 368 } 369