Enable retry

pull/15838/head
Muxi Yan 7 years ago
parent 9e3e64604d
commit b13eda3cb4
  1. 5
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
  2. 5
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
  3. 1
      src/objective-c/GRPCClient/private/GRPCHost.h
  4. 5
      src/objective-c/GRPCClient/private/GRPCHost.m

@ -55,4 +55,9 @@ typedef NS_ENUM(NSInteger, GRPCCompressAlgorithm) {
timeout:(int)timeout
forHost:(nonnull NSString *)host;
/** Enable/Disable automatic retry of gRPC calls on the channel. If automatic retry is enabled, the
* retry is controlled by server's service config. If automatic retry is disabled, failed calls are
* immediately returned to the application layer. */
+ (void)enableRetry:(BOOL)enabled forHost:(nonnull NSString *)host;
@end

@ -64,4 +64,9 @@
hostConfig.keepaliveTimeout = timeout;
}
+ (void)enableRetry:(BOOL)enabled forHost:(nonnull NSString *)host {
GRPCHost *hostConfig = [GRPCHost hostWithAddress:host];
hostConfig.retryEnabled = enabled;
}
@end

@ -38,6 +38,7 @@ struct grpc_channel_credentials;
@property(nonatomic) int keepaliveInterval;
@property(nonatomic) int keepaliveTimeout;
@property(nonatomic) id logContext;
@property(nonatomic) BOOL retryEnabled;
/** The following properties should only be modified for testing: */

@ -85,6 +85,7 @@ static NSMutableDictionary *kHostCache;
_secure = YES;
kHostCache[address] = self;
_compressAlgorithm = GRPC_COMPRESS_NONE;
_retryEnabled = YES;
}
#ifndef GRPC_CFSTREAM
[GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)];
@ -240,6 +241,10 @@ static NSMutableDictionary *kHostCache;
args[@GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER] = [NSNumber numberWithInt:1];
}
if (_retryEnabled == NO) {
args[@GRPC_ARG_ENABLE_RETRIES] = [NSNumber numberWithInt:0];
}
return args;
}

Loading…
Cancel
Save