GRPC Objective-C  1.25.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 
112 #import "GRPCCall.h"
113 #import "GRPCDispatchable.h"
114 
115 NS_ASSUME_NONNULL_BEGIN
116 
118 @class GRPCInterceptor;
119 @class GRPCRequestOptions;
120 @class GRPCCallOptions;
121 @protocol GRPCResponseHandler;
122 
127 
131 - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions
132  callOptions:(GRPCCallOptions *)callOptions;
133 
137 - (void)writeData:(id)data;
138 
142 - (void)finish;
143 
147 - (void)cancel;
148 
152 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
153 
154 @end
155 
161 
166 - (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager;
167 
168 @end
169 
184 
185 - (instancetype)init NS_UNAVAILABLE;
186 
187 + (instancetype) new NS_UNAVAILABLE;
188 
189 - (nullable instancetype)initWithFactories:(nullable NSArray<id<GRPCInterceptorFactory>> *)factories
190  previousInterceptor:(nullable id<GRPCResponseHandler>)previousInterceptor
191  transportID:(GRPCTransportID)transportID;
192 
197 - (void)shutDown;
198 
199 // Methods to forward GRPCInterceptorInterface calls to the next interceptor
200 
202 - (void)startNextInterceptorWithRequest:(GRPCRequestOptions *)requestOptions
203  callOptions:(GRPCCallOptions *)callOptions;
204 
206 - (void)writeNextInterceptorWithData:(id)data;
207 
209 - (void)finishNextInterceptor;
210 
212 - (void)cancelNextInterceptor;
213 
215 - (void)receiveNextInterceptorMessages:(NSUInteger)numberOfMessages;
216 
217 // Methods to forward GRPCResponseHandler callbacks to the previous object
218 
220 - (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata;
221 
223 - (void)forwardPreviousInterceptorWithData:(nullable id)data;
224 
226 - (void)forwardPreviousInterceptorCloseWithTrailingMetadata:
227  (nullable NSDictionary *)trailingMetadata
228  error:(nullable NSError *)error;
229 
232 
233 @end
234 
246 
247 - (instancetype)init NS_UNAVAILABLE;
248 + (instancetype) new NS_UNAVAILABLE;
249 
254 - (nullable instancetype)initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
255  dispatchQueue:(dispatch_queue_t)dispatchQueue;
256 
257 // Default implementation of GRPCInterceptorInterface
258 
259 - (void)startWithRequestOptions:(GRPCRequestOptions *)requestOptions
260  callOptions:(GRPCCallOptions *)callOptions;
261 - (void)writeData:(id)data;
262 - (void)finish;
263 - (void)cancel;
264 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
265 
266 // Default implementation of GRPCResponeHandler
267 
268 - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata;
269 - (void)didReceiveData:(id)data;
270 - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
271  error:(nullable NSError *)error;
272 - (void)didWriteData;
273 
274 @end
275 
276 NS_ASSUME_NONNULL_END
GRPCCall.h
GRPCTransportID
char *_Nonnull GRPCTransportID
The id of a transport implementation.
Definition: GRPCTypes.h:179
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:30
GRPCInterceptorInterface-p
The GRPCInterceptorInterface defines the request events that can occur to an interceptor.
Definition: GRPCInterceptor.h:126
-[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:245
-[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...
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:160
GRPCInterceptorManager
GRPCInterceptorManager is a helper class to forward messages between the interceptors.
Definition: GRPCInterceptor.h:183
-[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