Skip to content

Commit a517561

Browse files
authored
Support HeartbeatConsistencyChecks in Clone() (#2658)
* Support `HeartbeatConsistencyChecks` in `Clone()` * include heartbeatInterval
1 parent 7bec9df commit a517561

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/ReleaseNotes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Current package versions:
77
| [![StackExchange.Redis](https://img.shields.io/nuget/v/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis](https://img.shields.io/nuget/vpre/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis MyGet](https://img.shields.io/myget/stackoverflow/vpre/StackExchange.Redis.svg)](https://www.myget.org/feed/stackoverflow/package/nuget/StackExchange.Redis) |
88

99
## Unreleased
10-
No pending unreleased changes.
10+
11+
- Support `HeartbeatConsistencyChecks` and `HeartbeatInterval` in `Clone()` ([#2658 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2658))
1112

1213
## 2.7.23
1314

src/StackExchange.Redis/ConfigurationOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ public static ConfigurationOptions Parse(string configuration, bool ignoreUnknow
721721
setClientLibrary = setClientLibrary,
722722
LibraryName = LibraryName,
723723
Protocol = Protocol,
724+
heartbeatInterval = heartbeatInterval,
725+
heartbeatConsistencyChecks = heartbeatConsistencyChecks,
724726
};
725727

726728
/// <summary>

tests/StackExchange.Redis.Tests/ConfigTests.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
using StackExchange.Redis.Configuration;
1+
using Microsoft.Extensions.Logging.Abstractions;
2+
using StackExchange.Redis.Configuration;
23
using System;
34
using System.Globalization;
45
using System.IO;
56
using System.IO.Pipelines;
67
using System.Linq;
78
using System.Net;
89
using System.Net.Sockets;
10+
using System.Reflection;
911
using System.Security.Authentication;
1012
using System.Text;
13+
using System.Text.RegularExpressions;
1114
using System.Threading;
1215
using System.Threading.Tasks;
13-
using Microsoft.Extensions.Logging.Abstractions;
1416
using Xunit;
1517
using Xunit.Abstractions;
1618

@@ -25,6 +27,37 @@ public ConfigTests(ITestOutputHelper output, SharedConnectionFixture fixture) :
2527
public Version DefaultVersion = new (3, 0, 0);
2628
public Version DefaultAzureVersion = new (4, 0, 0);
2729

30+
[Fact]
31+
public void ExpectedFields()
32+
{
33+
// if this test fails, check that you've updated ConfigurationOptions.Clone(), then: fix the test!
34+
// this is a simple but pragmatic "have you considered?" check
35+
36+
var fields = Array.ConvertAll(typeof(ConfigurationOptions).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance),
37+
x => Regex.Replace(x.Name, """^<(\w+)>k__BackingField$""", "$1"));
38+
Array.Sort(fields);
39+
Assert.Equal(new[] {
40+
"abortOnConnectFail", "allowAdmin", "asyncTimeout", "backlogPolicy", "BeforeSocketConnect",
41+
"CertificateSelection", "CertificateValidation", "ChannelPrefix",
42+
"checkCertificateRevocation", "ClientName", "commandMap",
43+
"configChannel", "configCheckSeconds", "connectRetry",
44+
"connectTimeout", "DefaultDatabase", "defaultOptions",
45+
"defaultVersion", "EndPoints", "heartbeatConsistencyChecks",
46+
"heartbeatInterval", "includeDetailInExceptions", "includePerformanceCountersInExceptions",
47+
"keepAlive", "LibraryName", "loggerFactory",
48+
"password", "Protocol", "proxy",
49+
"reconnectRetryPolicy", "resolveDns", "responseTimeout",
50+
"ServiceName", "setClientLibrary", "SocketManager",
51+
"ssl",
52+
#if !NETFRAMEWORK
53+
"SslClientAuthenticationOptions",
54+
#endif
55+
"sslHost", "SslProtocols",
56+
"syncTimeout", "tieBreaker", "Tunnel",
57+
"user"
58+
}, fields);
59+
}
60+
2861
[Fact]
2962
public void SslProtocols_SingleValue()
3063
{

0 commit comments

Comments
 (0)