Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7759aa1

Browse files
committed
Update RedisSentinel default timeouts to 250ms + inline value in prop def
1 parent a968f1c commit 7759aa1

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

src/ServiceStack.Redis/RedisSentinel.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,54 +74,54 @@ public class RedisSentinel : IRedisSentinel
7474
/// <summary>
7575
/// Whether to routinely scan for other sentinel hosts (default true)
7676
/// </summary>
77-
public bool ScanForOtherSentinels { get; set; }
77+
public bool ScanForOtherSentinels { get; set; } = true;
7878

7979
/// <summary>
8080
/// What interval to scan for other sentinel hosts (default 10 mins)
8181
/// </summary>
82-
public TimeSpan RefreshSentinelHostsAfter { get; set; }
82+
public TimeSpan RefreshSentinelHostsAfter { get; set; } = TimeSpan.FromMinutes(10);
8383
private DateTime lastSentinelsRefresh;
8484

8585
/// <summary>
8686
/// How long to wait after failing before connecting to next redis instance (default 250ms)
8787
/// </summary>
88-
public TimeSpan WaitBetweenFailedHosts { get; set; }
88+
public TimeSpan WaitBetweenFailedHosts { get; set; } = TimeSpan.FromMilliseconds(250);
8989

9090
/// <summary>
9191
/// How long to retry connecting to hosts before throwing (default 60 secs)
9292
/// </summary>
93-
public TimeSpan MaxWaitBetweenFailedHosts { get; set; }
93+
public TimeSpan MaxWaitBetweenFailedHosts { get; set; } = TimeSpan.FromSeconds(60);
9494

9595
/// <summary>
9696
/// How long to wait after consecutive failed connection attempts to master before forcing
9797
/// a Sentinel to failover the current master (default 60 secs)
9898
/// </summary>
99-
public TimeSpan WaitBeforeForcingMasterFailover { get; set; }
99+
public TimeSpan WaitBeforeForcingMasterFailover { get; set; } = TimeSpan.FromSeconds(60);
100100

101101
/// <summary>
102-
/// The Max Connection time for Sentinel Worker (default 100ms)
102+
/// The Max Connection time for Sentinel Worker (default 250ms)
103103
/// </summary>
104-
public int SentinelWorkerConnectTimeoutMs { get; set; }
104+
public int SentinelWorkerConnectTimeoutMs { get; set; } = 250;
105105

106106
/// <summary>
107-
/// The Max TCP Socket Receive time for Sentinel Worker (default 100ms)
107+
/// The Max TCP Socket Receive time for Sentinel Worker (default 250ms)
108108
/// </summary>
109-
public int SentinelWorkerReceiveTimeoutMs { get; set; }
109+
public int SentinelWorkerReceiveTimeoutMs { get; set; } = 250;
110110

111111
/// <summary>
112-
/// The Max TCP Socket Send time for Sentinel Worker (default 100ms)
112+
/// The Max TCP Socket Send time for Sentinel Worker (default 250ms)
113113
/// </summary>
114-
public int SentinelWorkerSendTimeoutMs { get; set; }
114+
public int SentinelWorkerSendTimeoutMs { get; set; } = 250;
115115

116116
/// <summary>
117117
/// Reset client connections when Sentinel reports redis instance is subjectively down (default true)
118118
/// </summary>
119-
public bool ResetWhenSubjectivelyDown { get; set; }
119+
public bool ResetWhenSubjectivelyDown { get; set; } = true;
120120

121121
/// <summary>
122122
/// Reset client connections when Sentinel reports redis instance is objectively down (default true)
123123
/// </summary>
124-
public bool ResetWhenObjectivelyDown { get; set; }
124+
public bool ResetWhenObjectivelyDown { get; set; } = true;
125125

126126
internal string DebugId => $"";
127127

@@ -138,16 +138,6 @@ public RedisSentinel(IEnumerable<string> sentinelHosts, string masterName = null
138138
this.masterName = masterName ?? DefaultMasterName;
139139
IpAddressMap = new Dictionary<string, string>();
140140
RedisManagerFactory = (masters, slaves) => new PooledRedisClientManager(masters, slaves);
141-
ScanForOtherSentinels = true;
142-
RefreshSentinelHostsAfter = TimeSpan.FromMinutes(10);
143-
ResetWhenObjectivelyDown = true;
144-
ResetWhenSubjectivelyDown = true;
145-
SentinelWorkerConnectTimeoutMs = 100;
146-
SentinelWorkerReceiveTimeoutMs = 100;
147-
SentinelWorkerSendTimeoutMs = 100;
148-
WaitBetweenFailedHosts = TimeSpan.FromMilliseconds(250);
149-
MaxWaitBetweenFailedHosts = TimeSpan.FromSeconds(60);
150-
WaitBeforeForcingMasterFailover = TimeSpan.FromSeconds(60);
151141
}
152142

153143
/// <summary>

0 commit comments

Comments
 (0)