Skip to content

Commit

Permalink
Support HeartbeatConsistencyChecks in Clone() (#2658)
Browse files Browse the repository at this point in the history
* Support `HeartbeatConsistencyChecks` in `Clone()`
* include heartbeatInterval
  • Loading branch information
mgravell authored Feb 27, 2024
1 parent 7bec9df commit a517561
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Current package versions:
| [![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) |

## Unreleased
No pending unreleased changes.

- Support `HeartbeatConsistencyChecks` and `HeartbeatInterval` in `Clone()` ([#2658 by mgravell](https://github.com/StackExchange/StackExchange.Redis/pull/2658))

## 2.7.23

Expand Down
2 changes: 2 additions & 0 deletions src/StackExchange.Redis/ConfigurationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ public static ConfigurationOptions Parse(string configuration, bool ignoreUnknow
setClientLibrary = setClientLibrary,
LibraryName = LibraryName,
Protocol = Protocol,
heartbeatInterval = heartbeatInterval,
heartbeatConsistencyChecks = heartbeatConsistencyChecks,
};

/// <summary>
Expand Down
37 changes: 35 additions & 2 deletions tests/StackExchange.Redis.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using StackExchange.Redis.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using StackExchange.Redis.Configuration;
using System;
using System.Globalization;
using System.IO;
using System.IO.Pipelines;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security.Authentication;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Abstractions;
using Xunit;
using Xunit.Abstractions;

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

[Fact]
public void ExpectedFields()
{
// if this test fails, check that you've updated ConfigurationOptions.Clone(), then: fix the test!
// this is a simple but pragmatic "have you considered?" check

var fields = Array.ConvertAll(typeof(ConfigurationOptions).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance),
x => Regex.Replace(x.Name, """^<(\w+)>k__BackingField$""", "$1"));
Array.Sort(fields);
Assert.Equal(new[] {
"abortOnConnectFail", "allowAdmin", "asyncTimeout", "backlogPolicy", "BeforeSocketConnect",
"CertificateSelection", "CertificateValidation", "ChannelPrefix",
"checkCertificateRevocation", "ClientName", "commandMap",
"configChannel", "configCheckSeconds", "connectRetry",
"connectTimeout", "DefaultDatabase", "defaultOptions",
"defaultVersion", "EndPoints", "heartbeatConsistencyChecks",
"heartbeatInterval", "includeDetailInExceptions", "includePerformanceCountersInExceptions",
"keepAlive", "LibraryName", "loggerFactory",
"password", "Protocol", "proxy",
"reconnectRetryPolicy", "resolveDns", "responseTimeout",
"ServiceName", "setClientLibrary", "SocketManager",
"ssl",
#if !NETFRAMEWORK
"SslClientAuthenticationOptions",
#endif
"sslHost", "SslProtocols",
"syncTimeout", "tieBreaker", "Tunnel",
"user"
}, fields);
}

[Fact]
public void SslProtocols_SingleValue()
{
Expand Down

0 comments on commit a517561

Please sign in to comment.