gRPC  0.6.0
 All Classes Namespaces Functions Variables Enumerations Properties Pages
GRPCCall.h
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #import <Foundation/Foundation.h>
35 #import <gRPC/GRXWriter.h>
36 
37 @class GRPCMethodName;
38 
39 @class GRPCCall;
40 
41 // The gRPC protocol is an RPC protocol on top of HTTP2.
42 //
43 // While the most common type of RPC receives only one request message and
44 // returns only one response message, the protocol also supports RPCs that
45 // return multiple individual messages in a streaming fashion, RPCs that
46 // accept a stream of request messages, or RPCs with both streaming requests
47 // and responses.
48 //
49 // Conceptually, each gRPC call consists of a bidirectional stream of binary
50 // messages, with RPCs of the "non-streaming type" sending only one message in
51 // the corresponding direction (the protocol doesn't make any distinction).
52 //
53 // Each RPC uses a different HTTP2 stream, and thus multiple simultaneous RPCs
54 // can be multiplexed transparently on the same TCP connection.
55 @interface GRPCCall : NSObject<GRXWriter>
56 
57 // These HTTP2 headers will be passed to the server as part of this call. Each
58 // HTTP2 header is a name-value pair with string names and either string or binary values.
59 // The passed dictionary has to use NSString keys, corresponding to the header names. The
60 // value associated to each can be a NSString object or a NSData object. E.g.:
61 //
62 // call.requestMetadata = @{
63 // @"Authorization": @"Bearer ...",
64 // @"SomeBinaryHeader": someData
65 // };
66 //
67 // After the call is started, modifying this won't have any effect.
68 @property(nonatomic, readwrite) NSMutableDictionary *requestMetadata;
69 
70 // This isn't populated until the first event is delivered to the handler.
71 @property(atomic, readonly) NSDictionary *responseMetadata;
72 
73 // The request writer has to write NSData objects into the provided Writeable. The server will
74 // receive each of those separately and in order.
75 // A gRPC call might not complete until the request writer finishes. On the other hand, the
76 // request finishing doesn't necessarily make the call to finish, as the server might continue
77 // sending messages to the response side of the call indefinitely (depending on the semantics of
78 // the specific remote method called).
79 // To finish a call right away, invoke cancel.
80 - (instancetype)initWithHost:(NSString *)host
81  method:(GRPCMethodName *)method
82  requestsWriter:(id<GRXWriter>)requestsWriter NS_DESIGNATED_INITIALIZER;
83 
84 // Finishes the request side of this call, notifies the server that the RPC
85 // should be cancelled, and finishes the response side of the call with an error
86 // of code CANCELED.
87 - (void)cancel;
88 
89 // TODO(jcanizales): Let specify a deadline. As a category of GRXWriter?
90 @end
Definition: GRPCMethodName.h:42
Definition: GRPCCall.h:55
Definition: GRXWriter.h:88