GRPC Objective-C  1.73.0
GRPCInterceptor.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
116 #import "GRPCCall.h"
117 #import "GRPCDispatchable.h"
118 
119 NS_ASSUME_NONNULL_BEGIN
120 
122 @class GRPCInterceptor;
123 @class GRPCRequestOptions;
124 @class GRPCCallOptions;
125 @protocol GRPCResponseHandler;
126 
131 
135 - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions
136  callOptions:(GRPCCallOptions *)callOptions;
137 
141 - (void)writeData:(id)data;
142 
146 - (void)finish;
147 
151 - (void)cancel;
152 
156 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
157 
158 @end
159 
165 
170 - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager;
171 
172 @end
173 
188 
189 - (instancetype)init NS_UNAVAILABLE;
190 
191 + (instancetype)new NS_UNAVAILABLE;
192 
193 - (nullable instancetype)initWithFactories:(nullable NSArray<id<GRPCInterceptorFactory>> *)factories
194  previousInterceptor:(nullable id<GRPCResponseHandler>)previousInterceptor
195  transportID:(GRPCTransportID)transportID;
196 
201 - (void)shutDown;
202 
203 // Methods to forward GRPCInterceptorInterface calls to the next interceptor
204 
206 - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions
207  callOptions:(GRPCCallOptions *)callOptions;
208 
210 - (void)writeNextInterceptorWithData:(id)data;
211 
213 - (void)finishNextInterceptor;
214 
216 - (void)cancelNextInterceptor;
217 
219 - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages;
220 
221 // Methods to forward GRPCResponseHandler callbacks to the previous object
222 
224 - (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata;
225 
227 - (void)forwardPreviousInterceptorWithData:(nullable id)data;
228 
230 - (void)forwardPreviousInterceptorCloseWithTrailingMetadata:
231  (nullable NSDictionary *)trailingMetadata
232  error:(nullable NSError *)error;
233 
236 
237 @end
238 
250 
251 - (instancetype)init NS_UNAVAILABLE;
252 + (instancetype)new NS_UNAVAILABLE;
253 
258 - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
259  dispatchQueue:(dispatch_queue_t)dispatchQueue;
260 
261 // Default implementation of GRPCInterceptorInterface
262 
263 - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions
264  callOptions:(GRPCCallOptions *)callOptions;
265 - (void)writeData:(id)data;
266 - (void)finish;
267 - (void)cancel;
268 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
269 
270 // Default implementation of GRPCResponeHandler
271 
272 - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata;
273 - (void)didReceiveData:(id)data;
274 - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
275  error:(nullable NSError *)error;
276 - (void)didWriteData;
277 
278 @end
279 
280 NS_ASSUME_NONNULL_END
GRPCCall.h
GRPCDispatchable-p
An object that processes its methods with a dispatch queue.
Definition: GRPCDispatchable.h:23
-[GRPCInterceptorInterface-p finish]
void finish()
To finish the stream of requests.
-[GRPCInterceptorManager forwardPreviousInterceptorDidWriteData]
void forwardPreviousInterceptorDidWriteData()
Forward write completion to the previous interceptor in the chain.
-[GRPCInterceptor cancel]
void cancel()
To cancel the call.
-[GRPCInterceptor finish]
void finish()
To finish the stream of requests.
GRPCCallOptions
Immutable user configurable options for a gRPC call.
Definition: GRPCCallOptions.h:32
GRPCInterceptorInterface-p
The GRPCInterceptorInterface defines the request events that can occur to an interceptor.
Definition: GRPCInterceptor.h:130
-[GRPCInterceptorInterface-p cancel]
void cancel()
To cancel the call.
GRPCDispatchable.h
-[GRPCInterceptor NS_UNAVAILABLE]
instancetype NS_UNAVAILABLE()
-[GRPCInterceptorManager NS_UNAVAILABLE]
instancetype NS_UNAVAILABLE()
GRPCInterceptor
Base class for a gRPC interceptor.
Definition: GRPCInterceptor.h:249
-[GRPCInterceptorManager cancelNextInterceptor]
void cancelNextInterceptor()
Notify the next interceptor in the chain to cancel the call.
-[GRPCInterceptorManager shutDown]
void shutDown()
Notify the manager that the interceptor has shut down and the manager should release references to ot...
-[GRPCInterceptor didWriteData]
void didWriteData()
Issued when flow control is enabled for the call and a message written with GRPCCall2::writeData is p...
GRPCTransportID
const typedef char *_Nonnull GRPCTransportID
The id of a transport implementation.
Definition: GRPCTypes.h:172
GRPCRequestOptions
HTTP request parameters.
Definition: GRPCCall.h:102
GRPCInterceptorFactory-p
An interceptor factory object is used to create interceptor object for the call at the call start tim...
Definition: GRPCInterceptor.h:164
GRPCInterceptorManager
GRPCInterceptorManager is a helper class to forward messages between the interceptors.
Definition: GRPCInterceptor.h:187
-[GRPCInterceptorManager finishNextInterceptor]
void finishNextInterceptor()
Notify the next interceptor in the chain to finish the call.
GRPCResponseHandler-p
An object can implement this protocol to receive responses from server from a call.
Definition: GRPCCall.h:50