/** * Constructs an instance of GrpcTextToSpeechStub, using the given settings. This is protected so * that it is easy to make a subclass, but otherwise, the static factory methods should be * preferred. */ protected GrpcTextToSpeechStub( TextToSpeechStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings = GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder() .setMethodDescriptor(listVoicesMethodDescriptor) .build(); GrpcCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse> synthesizeSpeechTransportSettings = GrpcCallSettings.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder() .setMethodDescriptor(synthesizeSpeechMethodDescriptor) .build(); this.listVoicesCallable = callableFactory.createUnaryCallable( listVoicesTransportSettings, settings.listVoicesSettings(), clientContext); this.synthesizeSpeechCallable = callableFactory.createUnaryCallable( synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
/** * Create a Unary callable object with minimal grpc-specific functionality. * * @param grpcCallSettings the gRPC call settings * @param callSettings the Unary call settings * @param clientContext {@link ClientContext} to use to connect to the service. */ public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBaseUnaryCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, UnaryCallSettings<?, ?> callSettings, ClientContext clientContext) { UnaryCallable<RequestT, ResponseT> callable = new GrpcDirectCallable<>(grpcCallSettings.getMethodDescriptor()); if (grpcCallSettings.getParamsExtractor() != null) { callable = new GrpcUnaryRequestParamCallable<>(callable, grpcCallSettings.getParamsExtractor()); } callable = new GrpcExceptionCallable<>(callable, callSettings.getRetryableCodes()); callable = Callables.retrying(callable, callSettings, clientContext); return callable; }
/** * Create a client-streaming callable object with grpc-specific functionality. Designed for use by * generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @return {@link ClientStreamingCallable} callable object. */ @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { ClientStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectClientStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); callable = new GrpcExceptionClientStreamingCallable<>(callable, ImmutableSet.<StatusCode.Code>of()); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
public GrpcCallSettings<RequestT, ResponseT> build() { return new GrpcCallSettings<>(methodDescriptor, paramsExtractor); } }
/** * Create a Unary callable object with minimal grpc-specific functionality. * * @param grpcCallSettings the gRPC call settings * @param callSettings the Unary call settings * @param clientContext {@link ClientContext} to use to connect to the service. */ public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBaseUnaryCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, UnaryCallSettings<?, ?> callSettings, ClientContext clientContext) { UnaryCallable<RequestT, ResponseT> callable = new GrpcDirectCallable<>(grpcCallSettings.getMethodDescriptor()); if (grpcCallSettings.getParamsExtractor() != null) { callable = new GrpcUnaryRequestParamCallable<>(callable, grpcCallSettings.getParamsExtractor()); } callable = new GrpcExceptionCallable<>(callable, callSettings.getRetryableCodes()); callable = Callables.retrying(callable, callSettings, clientContext); return callable; }
/** * Create a bidirectional streaming callable object with grpc-specific functionality. Designed for * use by generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @return {@link BidiStreamingCallable} callable object. */ @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> BidiStreamingCallable<RequestT, ResponseT> createBidiStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { BidiStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectBidiStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); callable = new GrpcExceptionBidiStreamingCallable<>(callable, ImmutableSet.<StatusCode.Code>of()); callable = new TracedBidiCallable<>( callable, clientContext.getTracerFactory(), getSpanName(grpcCallSettings.getMethodDescriptor())); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
public GrpcCallSettings<RequestT, ResponseT> build() { return new GrpcCallSettings<>(methodDescriptor, paramsExtractor); } }
/** * Constructs an instance of GrpcTraceServiceStub, using the given settings. This is protected so * that it is easy to make a subclass, but otherwise, the static factory methods should be * preferred. */ protected GrpcTraceServiceStub( TraceServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<BatchWriteSpansRequest, Empty> batchWriteSpansTransportSettings = GrpcCallSettings.<BatchWriteSpansRequest, Empty>newBuilder() .setMethodDescriptor(batchWriteSpansMethodDescriptor) .build(); GrpcCallSettings<Span, Span> createSpanTransportSettings = GrpcCallSettings.<Span, Span>newBuilder() .setMethodDescriptor(createSpanMethodDescriptor) .build(); this.batchWriteSpansCallable = callableFactory.createUnaryCallable( batchWriteSpansTransportSettings, settings.batchWriteSpansSettings(), clientContext); this.createSpanCallable = callableFactory.createUnaryCallable( createSpanTransportSettings, settings.createSpanSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
ClientContext clientContext) { ServerStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectServerStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); if (grpcCallSettings.getParamsExtractor() != null) { callable = new GrpcServerStreamingRequestParamCallable<>( callable, grpcCallSettings.getParamsExtractor()); callable, clientContext.getTracerFactory(), getSpanName(grpcCallSettings.getMethodDescriptor()));
/** * Create a bidirectional streaming callable object with grpc-specific functionality. Designed for * use by generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @return {@link BidiStreamingCallable} callable object. */ @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> BidiStreamingCallable<RequestT, ResponseT> createBidiStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { BidiStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectBidiStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); callable = new GrpcExceptionBidiStreamingCallable<>(callable, ImmutableSet.<StatusCode.Code>of()); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
/** * Constructs an instance of GrpcErrorGroupServiceStub, using the given settings. This is * protected so that it is easy to make a subclass, but otherwise, the static factory methods * should be preferred. */ protected GrpcErrorGroupServiceStub( ErrorGroupServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<GetGroupRequest, ErrorGroup> getGroupTransportSettings = GrpcCallSettings.<GetGroupRequest, ErrorGroup>newBuilder() .setMethodDescriptor(getGroupMethodDescriptor) .build(); GrpcCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupTransportSettings = GrpcCallSettings.<UpdateGroupRequest, ErrorGroup>newBuilder() .setMethodDescriptor(updateGroupMethodDescriptor) .build(); this.getGroupCallable = callableFactory.createUnaryCallable( getGroupTransportSettings, settings.getGroupSettings(), clientContext); this.updateGroupCallable = callableFactory.createUnaryCallable( updateGroupTransportSettings, settings.updateGroupSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
ClientContext clientContext) { ServerStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectServerStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); if (grpcCallSettings.getParamsExtractor() != null) { callable = new GrpcServerStreamingRequestParamCallable<>( callable, grpcCallSettings.getParamsExtractor());
/** * Create a client-streaming callable object with grpc-specific functionality. Designed for use by * generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @return {@link ClientStreamingCallable} callable object. */ @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { ClientStreamingCallable<RequestT, ResponseT> callable = new GrpcDirectClientStreamingCallable<>(grpcCallSettings.getMethodDescriptor()); callable = new GrpcExceptionClientStreamingCallable<>(callable, ImmutableSet.<StatusCode.Code>of()); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
/** * Constructs an instance of GrpcTextToSpeechStub, using the given settings. This is protected so * that it is easy to make a subclass, but otherwise, the static factory methods should be * preferred. */ protected GrpcTextToSpeechStub( TextToSpeechStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings = GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder() .setMethodDescriptor(listVoicesMethodDescriptor) .build(); GrpcCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse> synthesizeSpeechTransportSettings = GrpcCallSettings.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder() .setMethodDescriptor(synthesizeSpeechMethodDescriptor) .build(); this.listVoicesCallable = callableFactory.createUnaryCallable( listVoicesTransportSettings, settings.listVoicesSettings(), clientContext); this.synthesizeSpeechCallable = callableFactory.createUnaryCallable( synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
/** * Create a callable object with grpc-specific functionality. Designed for use by generated code. * * @param grpcCallSettings the gRPC call settings */ public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, UnaryCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext) { UnaryCallable<RequestT, ResponseT> callable = createBaseUnaryCallable(grpcCallSettings, callSettings, clientContext); callable = new TracedUnaryCallable<>( callable, clientContext.getTracerFactory(), getSpanName(grpcCallSettings.getMethodDescriptor())); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
/** * Constructs an instance of GrpcPredictionServiceStub, using the given settings. This is * protected so that it is easy to make a subclass, but otherwise, the static factory methods * should be preferred. */ protected GrpcPredictionServiceStub( PredictionServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<PredictRequest, PredictResponse> predictTransportSettings = GrpcCallSettings.<PredictRequest, PredictResponse>newBuilder() .setMethodDescriptor(predictMethodDescriptor) .build(); this.predictCallable = callableFactory.createUnaryCallable( predictTransportSettings, settings.predictSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
/** * Create a callable object with grpc-specific functionality. Designed for use by generated code. * * @param grpcCallSettings the gRPC call settings */ public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, UnaryCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext) { UnaryCallable<RequestT, ResponseT> callable = createBaseUnaryCallable(grpcCallSettings, callSettings, clientContext); callable = new TracedUnaryCallable<>( callable, clientContext.getTracerFactory(), getSpanName(grpcCallSettings.getMethodDescriptor())); return callable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
/** * Constructs an instance of GrpcSessionsStub, using the given settings. This is protected so that * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. */ protected GrpcSessionsStub( SessionsStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<DetectIntentRequest, DetectIntentResponse> detectIntentTransportSettings = GrpcCallSettings.<DetectIntentRequest, DetectIntentResponse>newBuilder() .setMethodDescriptor(detectIntentMethodDescriptor) .build(); GrpcCallSettings<StreamingDetectIntentRequest, StreamingDetectIntentResponse> streamingDetectIntentTransportSettings = GrpcCallSettings .<StreamingDetectIntentRequest, StreamingDetectIntentResponse>newBuilder() .setMethodDescriptor(streamingDetectIntentMethodDescriptor) .build(); this.detectIntentCallable = callableFactory.createUnaryCallable( detectIntentTransportSettings, settings.detectIntentSettings(), clientContext); this.streamingDetectIntentCallable = callableFactory.createBidiStreamingCallable( streamingDetectIntentTransportSettings, settings.streamingDetectIntentSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }
/** * Create a callable object that represents a batching API method. Designed for use by generated * code. * * @param grpcCallSettings the gRPC call settings * @param batchingCallSettings {@link BatchingCallSettings} to configure the batching related * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @return {@link UnaryCallable} callable object. */ @BetaApi("The surface for batching is not stable yet and may change in the future.") public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, BatchingCallSettings<RequestT, ResponseT> batchingCallSettings, ClientContext clientContext) { UnaryCallable<RequestT, ResponseT> baseCallable = createBaseUnaryCallable(grpcCallSettings, batchingCallSettings, clientContext); // NOTE: Since batching happens asynchronously and the outermost callable simply buffers the // request. Tracing will only start on the inner callable that accepts the batch. UnaryCallable<RequestT, ResponseT> tracedCallable = new TracedBatchingCallable<>( baseCallable, clientContext.getTracerFactory(), getSpanName(grpcCallSettings.getMethodDescriptor()), batchingCallSettings.getBatchingDescriptor()); UnaryCallable<RequestT, ResponseT> batchingCallable = Callables.batching(tracedCallable, batchingCallSettings, clientContext); return batchingCallable.withDefaultCallContext(clientContext.getDefaultCallContext()); }
/** * Constructs an instance of GrpcSessionsStub, using the given settings. This is protected so that * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. */ protected GrpcSessionsStub( SessionsStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; GrpcCallSettings<DetectIntentRequest, DetectIntentResponse> detectIntentTransportSettings = GrpcCallSettings.<DetectIntentRequest, DetectIntentResponse>newBuilder() .setMethodDescriptor(detectIntentMethodDescriptor) .build(); GrpcCallSettings<StreamingDetectIntentRequest, StreamingDetectIntentResponse> streamingDetectIntentTransportSettings = GrpcCallSettings .<StreamingDetectIntentRequest, StreamingDetectIntentResponse>newBuilder() .setMethodDescriptor(streamingDetectIntentMethodDescriptor) .build(); this.detectIntentCallable = callableFactory.createUnaryCallable( detectIntentTransportSettings, settings.detectIntentSettings(), clientContext); this.streamingDetectIntentCallable = callableFactory.createBidiStreamingCallable( streamingDetectIntentTransportSettings, settings.streamingDetectIntentSettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); }