Add channelOptionsHash: to GRPCCChannelOptions

pull/16190/head
Muxi Yan 6 years ago
parent f48c90606f
commit d578b43218
  1. 5
      src/objective-c/GRPCClient/GRPCCallOptions.h
  2. 24
      src/objective-c/GRPCClient/GRPCCallOptions.m
  3. 19
      src/objective-c/GRPCClient/private/GRPCChannelPool.m

@ -193,6 +193,11 @@ typedef NS_ENUM(NSInteger, GRPCTransportType) {
*/
- (BOOL)isChannelOptionsEqualTo:(GRPCCallOptions *)callOptions;
/**
* Hash for channel options.
*/
@property(readonly) NSUInteger channelOptionsHash;
@end
@interface GRPCMutableCallOptions : GRPCCallOptions<NSCopying, NSMutableCopying>

@ -267,6 +267,30 @@ static NSUInteger kDefaultChannelID = 0;
return YES;
}
- (NSUInteger)channelOptionsHash {
NSUInteger result = 0;
result ^= _userAgentPrefix.hash;
result ^= _responseSizeLimit;
result ^= _compressAlgorithm;
result ^= _enableRetry;
result ^= (unsigned int)(_keepaliveInterval * 1000);
result ^= (unsigned int)(_keepaliveTimeout * 1000);
result ^= (unsigned int)(_connectMinTimeout * 1000);
result ^= (unsigned int)(_connectInitialBackoff * 1000);
result ^= (unsigned int)(_connectMaxBackoff * 1000);
result ^= _additionalChannelArgs.hash;
result ^= _PEMRootCertificates.hash;
result ^= _PEMPrivateKey.hash;
result ^= _PEMCertChain.hash;
result ^= _hostNameOverride.hash;
result ^= _transportType;
result ^= [_logContext hash];
result ^= _channelPoolDomain.hash;
result ^= _channelID;
return result;
}
@end
@implementation GRPCMutableCallOptions

@ -153,24 +153,7 @@ extern const char *kCFStreamVarName;
- (NSUInteger)hash {
NSUInteger result = 0;
result ^= _host.hash;
result ^= _callOptions.userAgentPrefix.hash;
result ^= _callOptions.responseSizeLimit;
result ^= _callOptions.compressAlgorithm;
result ^= _callOptions.enableRetry;
result ^= (unsigned int)(_callOptions.keepaliveInterval * 1000);
result ^= (unsigned int)(_callOptions.keepaliveTimeout * 1000);
result ^= (unsigned int)(_callOptions.connectMinTimeout * 1000);
result ^= (unsigned int)(_callOptions.connectInitialBackoff * 1000);
result ^= (unsigned int)(_callOptions.connectMaxBackoff * 1000);
result ^= _callOptions.additionalChannelArgs.hash;
result ^= _callOptions.PEMRootCertificates.hash;
result ^= _callOptions.PEMPrivateKey.hash;
result ^= _callOptions.PEMCertChain.hash;
result ^= _callOptions.hostNameOverride.hash;
result ^= _callOptions.transportType;
result ^= [_callOptions.logContext hash];
result ^= _callOptions.channelPoolDomain.hash;
result ^= _callOptions.channelID;
result ^= _callOptions.channelOptionsHash;
return result;
}

Loading…
Cancel
Save