|
| 1 | +/* |
| 2 | + * Copyright 2018 Google LLC |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions are |
| 6 | + * met: |
| 7 | + * |
| 8 | + * * Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * * Redistributions in binary form must reproduce the above |
| 11 | + * copyright notice, this list of conditions and the following disclaimer |
| 12 | + * in the documentation and/or other materials provided with the |
| 13 | + * distribution. |
| 14 | + * * Neither the name of Google LLC nor the names of its |
| 15 | + * contributors may be used to endorse or promote products derived from |
| 16 | + * this software without specific prior written permission. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | +package com.google.api.gax.grpc; |
| 31 | + |
| 32 | +import com.google.api.core.BetaApi; |
| 33 | +import com.google.api.gax.rpc.BatchingCallSettings; |
| 34 | +import com.google.api.gax.rpc.BidiStreamingCallable; |
| 35 | +import com.google.api.gax.rpc.ClientContext; |
| 36 | +import com.google.api.gax.rpc.ClientStreamingCallable; |
| 37 | +import com.google.api.gax.rpc.OperationCallSettings; |
| 38 | +import com.google.api.gax.rpc.OperationCallable; |
| 39 | +import com.google.api.gax.rpc.PagedCallSettings; |
| 40 | +import com.google.api.gax.rpc.ServerStreamingCallSettings; |
| 41 | +import com.google.api.gax.rpc.ServerStreamingCallable; |
| 42 | +import com.google.api.gax.rpc.StreamingCallSettings; |
| 43 | +import com.google.api.gax.rpc.UnaryCallSettings; |
| 44 | +import com.google.api.gax.rpc.UnaryCallable; |
| 45 | +import com.google.longrunning.Operation; |
| 46 | +import com.google.longrunning.stub.OperationsStub; |
| 47 | + |
| 48 | +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") |
| 49 | +public interface GrpcStubCallableFactory { |
| 50 | + |
| 51 | + /** |
| 52 | + * Create a callable object with grpc-specific functionality. Designed for use by generated code. |
| 53 | + * |
| 54 | + * @param grpcCallSettings the gRPC call settings |
| 55 | + */ |
| 56 | + public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable( |
| 57 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 58 | + UnaryCallSettings<RequestT, ResponseT> callSettings, |
| 59 | + ClientContext clientContext); |
| 60 | + |
| 61 | + /** |
| 62 | + * Create a paged callable object that represents a paged API method. Designed for use by |
| 63 | + * generated code. |
| 64 | + * |
| 65 | + * @param grpcCallSettings the gRPC call settings |
| 66 | + * @param pagedCallSettings {@link PagedCallSettings} to configure the paged settings with. |
| 67 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 68 | + * @return {@link UnaryCallable} callable object. |
| 69 | + */ |
| 70 | + public <RequestT, ResponseT, PagedListResponseT> |
| 71 | + UnaryCallable<RequestT, PagedListResponseT> createPagedCallable( |
| 72 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 73 | + PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings, |
| 74 | + ClientContext clientContext); |
| 75 | + |
| 76 | + /** |
| 77 | + * Create a callable object that represents a batching API method. Designed for use by generated |
| 78 | + * code. |
| 79 | + * |
| 80 | + * @param grpcCallSettings the gRPC call settings |
| 81 | + * @param batchingCallSettings {@link BatchingCallSettings} to configure the batching related |
| 82 | + * settings with. |
| 83 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 84 | + * @return {@link UnaryCallable} callable object. |
| 85 | + */ |
| 86 | + @BetaApi("The surface for batching is not stable yet and may change in the future.") |
| 87 | + public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable( |
| 88 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 89 | + BatchingCallSettings<RequestT, ResponseT> batchingCallSettings, |
| 90 | + ClientContext clientContext); |
| 91 | + |
| 92 | + /** |
| 93 | + * Creates a callable object that represents a long-running operation. Designed for use by |
| 94 | + * generated code. |
| 95 | + * |
| 96 | + * @param grpcCallSettings the gRPC call settings |
| 97 | + * @param operationCallSettings {@link OperationCallSettings} to configure the method-level |
| 98 | + * settings with. |
| 99 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 100 | + * @param operationsStub {@link OperationsStub} to use to poll for updates on the Operation. |
| 101 | + * @return {@link OperationCallable} callable object. |
| 102 | + */ |
| 103 | + @BetaApi( |
| 104 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 105 | + public <RequestT, ResponseT, MetadataT> |
| 106 | + OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable( |
| 107 | + GrpcCallSettings<RequestT, Operation> grpcCallSettings, |
| 108 | + OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, |
| 109 | + ClientContext clientContext, |
| 110 | + OperationsStub operationsStub); |
| 111 | + |
| 112 | + /** |
| 113 | + * Create a bidirectional streaming callable object with grpc-specific functionality. Designed for |
| 114 | + * use by generated code. |
| 115 | + * |
| 116 | + * @param grpcCallSettings the gRPC call settings |
| 117 | + * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level |
| 118 | + * settings with. |
| 119 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 120 | + * @return {@link BidiStreamingCallable} callable object. |
| 121 | + */ |
| 122 | + @BetaApi("The surface for streaming is not stable yet and may change in the future.") |
| 123 | + public <RequestT, ResponseT> |
| 124 | + BidiStreamingCallable<RequestT, ResponseT> createBidiStreamingCallable( |
| 125 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 126 | + StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, |
| 127 | + ClientContext clientContext); |
| 128 | + |
| 129 | + /** |
| 130 | + * Create a server-streaming callable with grpc-specific functionality. Designed for use by |
| 131 | + * generated code. |
| 132 | + * |
| 133 | + * @param grpcCallSettings the gRPC call settings |
| 134 | + * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level |
| 135 | + * settings with. |
| 136 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 137 | + */ |
| 138 | + @BetaApi("The surface for streaming is not stable yet and may change in the future.") |
| 139 | + public <RequestT, ResponseT> |
| 140 | + ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable( |
| 141 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 142 | + ServerStreamingCallSettings<RequestT, ResponseT> streamingCallSettings, |
| 143 | + ClientContext clientContext); |
| 144 | + |
| 145 | + /** |
| 146 | + * Create a client-streaming callable object with grpc-specific functionality. Designed for use by |
| 147 | + * generated code. |
| 148 | + * |
| 149 | + * @param grpcCallSettings the gRPC call settings |
| 150 | + * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level |
| 151 | + * settings with. |
| 152 | + * @param clientContext {@link ClientContext} to use to connect to the service. |
| 153 | + * @return {@link ClientStreamingCallable} callable object. |
| 154 | + */ |
| 155 | + @BetaApi("The surface for streaming is not stable yet and may change in the future.") |
| 156 | + public <RequestT, ResponseT> |
| 157 | + ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable( |
| 158 | + GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, |
| 159 | + StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, |
| 160 | + ClientContext clientContext); |
| 161 | +} |
0 commit comments