aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-10-16 18:28:16 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-10-16 18:28:16 -0700
commitad5485ae4ef4ec31cb6b3ed54876fd9868343388 (patch)
tree24487565740e640256ae3bc5a7a27208379140e4
parentbc292b87c26ea8f6465443a152e86b3ed71e585b (diff)
Make channel args immutable
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m10
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelFactory.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.m2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m2
10 files changed, 18 insertions, 12 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 495af5ebe8..2274fa5d6a 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -86,8 +86,14 @@
return nil;
}
- NSMutableDictionary *channelArgs = config.channelArgs;
- [channelArgs addEntriesFromDictionary:config.callOptions.additionalChannelArgs];
+ NSDictionary *channelArgs;
+ if (config.callOptions.additionalChannelArgs.count != 0) {
+ NSMutableDictionary *args = [config.channelArgs copy];
+ [args addEntriesFromDictionary:config.callOptions.additionalChannelArgs];
+ channelArgs = args;
+ } else {
+ channelArgs = config.channelArgs;
+ }
id<GRPCChannelFactory> factory = config.channelFactory;
grpc_channel *unmanaged_channel = [factory createChannelWithHost:host channelArgs:channelArgs];
return [[GRPCChannel alloc] initWithUnmanagedChannel:unmanaged_channel configuration:config];
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCChannelFactory.h
index e44f8260df..492145da80 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelFactory.h
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol GRPCChannelFactory
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args;
+ channelArgs:(nullable NSDictionary *)args;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
index 2a99089d2f..1984919fa7 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
@@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(strong, readonly) GRPCCallOptions *callOptions;
@property(readonly) id<GRPCChannelFactory> channelFactory;
-@property(readonly) NSMutableDictionary *channelArgs;
+@property(readonly) NSDictionary *channelArgs;
- (nullable instancetype)initWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions;
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
index 10a15f5255..11c9d4be8d 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
@@ -76,7 +76,7 @@ const NSTimeInterval kChannelDestroyDelay = 30;
}
}
-- (NSMutableDictionary *)channelArgs {
+- (NSDictionary *)channelArgs {
NSMutableDictionary *args = [NSMutableDictionary new];
NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING;
diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
index 97e1ae920a..738dfdb737 100644
--- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
+++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable instancetype)sharedInstance;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args;
+ channelArgs:(nullable NSDictionary *)args;
- (nullable instancetype)init NS_UNAVAILABLE;
diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
index 5c0fe16d39..00b388ebbe 100644
--- a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
+++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
@@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args {
+ channelArgs:(nullable NSDictionary *)args {
// Remove client authority filter since that is not supported
args[@GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER] = [NSNumber numberWithInt:1];
@@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableArray *)args {
+ channelArgs:(nullable NSDictionary *)args {
[NSException raise:NSInvalidArgumentException
format:@"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel."];
return nil;
diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
index 905a181ca7..2d471aebed 100644
--- a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
+++ b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable instancetype)sharedInstance;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args;
+ channelArgs:(nullable NSDictionary *)args;
- (nullable instancetype)init NS_UNAVAILABLE;
diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
index 41860bf6ff..d969b887b4 100644
--- a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
+++ b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
@@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args {
+ channelArgs:(nullable NSDictionary *)args {
grpc_channel_args *coreChannelArgs = BuildChannelArgs([args copy]);
grpc_channel *unmanagedChannel =
grpc_insecure_channel_create(host.UTF8String, coreChannelArgs, NULL);
diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
index ab5eee478e..82af0dc3e6 100644
--- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
+++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
@@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
error:(NSError **)errorPtr;
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableDictionary *)args;
+ channelArgs:(nullable NSDictionary *)args;
- (nullable instancetype)init NS_UNAVAILABLE;
diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
index a0d56e4bdc..277823c4e3 100644
--- a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
+++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
@@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
- channelArgs:(nullable NSMutableArray *)args {
+ channelArgs:(nullable NSDictionary *)args {
grpc_channel_args *coreChannelArgs = BuildChannelArgs([args copy]);
grpc_channel *unmanagedChannel =
grpc_secure_channel_create(_channelCreds, host.UTF8String, coreChannelArgs, NULL);