GRPC Objective-C  1.25.0
ProtoRPC.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 
19 #import <Foundation/Foundation.h>
20 
21 // import legacy header for compatibility with users using the ProtoRPC interface
22 #import "ProtoRPCLegacy.h"
23 
24 #import "ProtoMethod.h"
25 
26 NS_ASSUME_NONNULL_BEGIN
27 
28 @class GRPCRequestOptions;
29 @class GRPCCallOptions;
30 @class GPBMessage;
31 
33 @protocol GRPCProtoResponseHandler<NSObject>
34 
35 @required
36 
41 @property(atomic, readonly) dispatch_queue_t dispatchQueue;
42 
43 @optional
44 
48 - (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata;
49 
53 - (void)didReceiveProtoMessage:(nullable GPBMessage *)message;
54 
61 - (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
62  error:(nullable NSError *)error;
63 
69 - (void)didWriteMessage;
70 
71 @end
72 
78 
86 - (nullable instancetype)initWithResponseHandler:(void (^)(GPBMessage *, NSError *))handler
87  responseDispatchQueue:(nullable dispatch_queue_t)dispatchQueue;
88 
90 @property(readonly, nullable) NSDictionary *responseHeaders;
91 
93 @property(readonly, nullable) NSDictionary *responseTrailers;
94 
95 @end
96 
98 @interface GRPCUnaryProtoCall : NSObject
99 
100 - (instancetype)init NS_UNAVAILABLE;
101 
102 + (instancetype) new NS_UNAVAILABLE;
103 
108 - (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
109  message:(GPBMessage *)message
110  responseHandler:(id<GRPCProtoResponseHandler>)handler
111  callOptions:(nullable GRPCCallOptions *)callOptions
112  responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
113 
117 - (void)start;
118 
124 - (void)cancel;
125 
126 @end
127 
129 @interface GRPCStreamingProtoCall : NSObject
130 
131 - (instancetype)init NS_UNAVAILABLE;
132 
133 + (instancetype) new NS_UNAVAILABLE;
134 
139 - (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
140  responseHandler:(id<GRPCProtoResponseHandler>)handler
141  callOptions:(nullable GRPCCallOptions *)callOptions
142  responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
143 
147 - (void)start;
148 
154 - (void)cancel;
155 
160 - (void)writeMessage:(GPBMessage *)message;
161 
166 - (void)finish;
167 
176 - (void)receiveNextMessage;
177 
186 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
187 
188 @end
189 
190 NS_ASSUME_NONNULL_END
ProtoMethod.h
-[GRPCStreamingProtoCall cancel]
void cancel()
Cancel the request of this call at best effort.
-[GRPCUnaryProtoCall start]
void start()
Start the call.
GRPCUnaryResponseHandler
A convenience class of objects that act as response handlers of calls.
Definition: ProtoRPC.h:77
-[GRPCProtoResponseHandler-p didWriteMessage]
void didWriteMessage()
Issued when flow control is enabled for the call and a message (written with writeMessage: method of ...
GRPCUnaryResponseHandler::responseHeaders
NSDictionary * responseHeaders
Response headers received during the call.
Definition: ProtoRPC.h:90
GRPCCallOptions
Immutable user configurable options for a gRPC call.
Definition: GRPCCallOptions.h:30
GRPCUnaryResponseHandler::responseTrailers
NSDictionary * responseTrailers
Response trailers received during the call.
Definition: ProtoRPC.h:93
-[GRPCStreamingProtoCall NS_UNAVAILABLE]
instancetype NS_UNAVAILABLE()
-[GRPCStreamingProtoCall receiveNextMessage]
void receiveNextMessage()
Tell gRPC to receive another message.
ProtoRPCLegacy.h
GRPCStreamingProtoCall
A client-streaming RPC call with Protobuf.
Definition: ProtoRPC.h:129
GRPCUnaryProtoCall
A unary-request RPC call with Protobuf.
Definition: ProtoRPC.h:98
-[GRPCStreamingProtoCall start]
void start()
Start the call.
-[GRPCUnaryProtoCall NS_UNAVAILABLE]
instancetype NS_UNAVAILABLE()
GRPCRequestOptions
HTTP request parameters.
Definition: GRPCCall.h:102
-[GRPCUnaryProtoCall cancel]
void cancel()
Cancel the request of this call at best effort.
GRPCProtoResponseHandler-p::dispatchQueue
dispatch_queue_t dispatchQueue
All the responses must be issued to a user-provided dispatch queue.
Definition: ProtoRPC.h:41
-[GRPCStreamingProtoCall finish]
void finish()
Finish the RPC request and half-close the call.
GRPCProtoResponseHandler-p
An object can implement this protocol to receive responses from server from a call.
Definition: ProtoRPC.h:33