Debian Codegraph @

src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h

raw
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 #include <grpc/grpc.h>
22
23 @protocol GRPCChannelFactory;
24
25 @class GRPCCompletionQueue;
26 @class GRPCCallOptions;
27 @class GRPCChannelConfiguration;
28 struct grpc_channel_credentials;
29
30 NS_ASSUME_NONNULL_BEGIN
31
32 /**
33 * Signature for the channel. If two channel's signatures are the same and connect to the same
34 * remote, they share the same underlying \a GRPCChannel object.
35 */
36 @interface GRPCChannelConfiguration : NSObject <NSCopying>
37
38 - (instancetype)init NS_UNAVAILABLE;
39
40 + (instancetype)new NS_UNAVAILABLE;
41
42 /** The host that this channel is connected to. */
43 @property(copy, readonly) NSString *host;
44
45 /**
46 * Options of the corresponding call. Note that only the channel-related options are of interest to
47 * this class.
48 */
49 @property(readonly) GRPCCallOptions *callOptions;
50
51 /** Acquire the factory to generate a new channel with current configurations. */
52 @property(readonly) id<GRPCChannelFactory> channelFactory;
53
54 /** Acquire the dictionary of channel args with current configurations. */
55 @property(copy, readonly) NSDictionary *channelArgs;
56
57 - (nullable instancetype)initWithHost:(NSString *)host
58 callOptions:(GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER;
59
60 @end
61
62 /**
63 * Each separate instance of this class represents at least one TCP connection to the provided host.
64 */
65 @interface GRPCChannel : NSObject
66
67 - (nullable instancetype)init NS_UNAVAILABLE;
68
69 + (nullable instancetype)new NS_UNAVAILABLE;
70
71 /**
72 * Create a channel with remote \a host and signature \a channelConfigurations.
73 */
74 - (nullable instancetype)initWithChannelConfiguration:
75 (GRPCChannelConfiguration *)channelConfiguration NS_DESIGNATED_INITIALIZER;
76
77 /**
78 * Create a grpc core call object (grpc_call) from this channel. If no call is created, NULL is
79 * returned.
80 */
81 - (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
82 completionQueue:(GRPCCompletionQueue *)queue
83 callOptions:(GRPCCallOptions *)callOptions;
84
85 @end
86
87 NS_ASSUME_NONNULL_END