GRPC Objective-C  1.73.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 
80 @interface GRPCUnaryResponseHandler<ResponseType> : NSObject <GRPCProtoResponseHandler>
81 
89 - (nullable instancetype)initWithResponseHandler:(void (^)(ResponseType, NSError *))handler
90  responseDispatchQueue:(nullable dispatch_queue_t)dispatchQueue;
91 
93 @property(readonly, nullable) NSDictionary *responseHeaders;
94 
96 @property(readonly, nullable) NSDictionary *responseTrailers;
97 
98 @end
99 
101 @interface GRPCUnaryProtoCall : NSObject
102 
103 - (instancetype)init NS_UNAVAILABLE;
104 
105 + (instancetype)new NS_UNAVAILABLE;
106 
111 - (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
112  message:(GPBMessage *)message
113  responseHandler:(id<GRPCProtoResponseHandler>)handler
114  callOptions:(nullable GRPCCallOptions *)callOptions
115  responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
116 
120 - (void)start;
121 
127 - (void)cancel;
128 
129 @end
130 
132 @interface GRPCStreamingProtoCall : NSObject
133 
134 - (instancetype)init NS_UNAVAILABLE;
135 
136 + (instancetype)new NS_UNAVAILABLE;
137 
142 - (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
143  responseHandler:(id<GRPCProtoResponseHandler>)handler
144  callOptions:(nullable GRPCCallOptions *)callOptions
145  responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
146 
150 - (void)start;
151 
157 - (void)cancel;
158 
163 - (void)writeMessage:(GPBMessage *)message;
164 
169 - (void)finish;
170 
179 - (void)receiveNextMessage;
180 
189 - (void)receiveNextMessages:(NSUInteger)numberOfMessages;
190 
191 @end
192 
193 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:80
-[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:93
GRPCCallOptions
Immutable user configurable options for a gRPC call.
Definition: GRPCCallOptions.h:32
GRPCUnaryResponseHandler::responseTrailers
NSDictionary * responseTrailers
Response trailers received during the call.
Definition: ProtoRPC.h:96
-[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:132
GRPCUnaryProtoCall
A unary-request RPC call with Protobuf.
Definition: ProtoRPC.h:101
-[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