aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCChannelPool.h
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-11-08 22:01:10 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-11-08 22:01:10 -0800
commit37dbad80d5254f9bf17076d12b22b7a081e6e9dc (patch)
tree367a86331b789917812b15ec4dde636b32560023 /src/objective-c/GRPCClient/private/GRPCChannelPool.h
parentd72d5b2c8eaa8a434a7db4624fe6a45bc0d6bde4 (diff)
Refactor channel pool
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCChannelPool.h')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.h55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
index f99c0ba4dc..24c0a8df11 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
@@ -29,28 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
@class GRPCChannel;
-/** Caching signature of a channel. */
-@interface GRPCChannelConfiguration : NSObject<NSCopying>
-
-/** The host that this channel is connected to. */
-@property(copy, readonly) NSString *host;
-
-/**
- * Options of the corresponding call. Note that only the channel-related options are of interest to
- * this class.
- */
-@property(strong, readonly) GRPCCallOptions *callOptions;
-
-/** Acquire the factory to generate a new channel with current configurations. */
-@property(readonly) id<GRPCChannelFactory> channelFactory;
-
-/** Acquire the dictionary of channel args with current configurations. */
-@property(copy, readonly) NSDictionary *channelArgs;
-
-- (nullable instancetype)initWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions;
-
-@end
-
/**
* Manage the pool of connected channels. When a channel is no longer referenced by any call,
* destroy the channel after a certain period of time elapsed.
@@ -58,19 +36,38 @@ NS_ASSUME_NONNULL_BEGIN
@interface GRPCChannelPool : NSObject
/**
+ * Get the singleton instance
+ */
++ (nullable instancetype)sharedInstance;
+
+/**
* Return a channel with a particular configuration. If the channel does not exist, execute \a
* createChannel then add it in the pool. If the channel exists, increase its reference count.
*/
-- (GRPCChannel *)channelWithConfiguration:(GRPCChannelConfiguration *)configuration;
+- (GRPCChannel *)channelWithHost:(NSString *)host
+ callOptions:(GRPCCallOptions *)callOptions;
+
+/**
+ * This method is deprecated.
+ *
+ * Destroy all open channels and close their connections.
+ */
++ (void)closeOpenConnections;
-/** Remove a channel from the pool. */
-- (void)removeChannel:(GRPCChannel *)channel;
+// Test-only methods below
-/** Clear all channels in the pool. */
-- (void)removeAllChannels;
+/**
+ * Return a channel with a special destroy delay. If \a destroyDelay is 0, use the default destroy
+ * delay.
+ */
+- (GRPCChannel *)channelWithHost:(NSString *)host
+ callOptions:(GRPCCallOptions *)callOptions
+ destroyDelay:(NSTimeInterval)destroyDelay;
-/** Clear all channels in the pool and destroy the channels. */
-- (void)removeAndCloseAllChannels;
+/**
+ * Simulate a network transition event and destroy all channels.
+ */
+- (void)destroyAllChannels;
@end