Skip to content

Commit 2bc189c

Browse files
Richard TappendenNickCraver
authored andcommitted
Isconnecting (#803)
* Add IsConnecting property to determine whether the multiplexor is trying to establish a connection. * spaces * Use the correct enum to determine 'IsConnecting'
1 parent 9f4dea4 commit 2bc189c

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,20 @@ public bool IsConnected
18391839
}
18401840
}
18411841

1842+
/// <summary>
1843+
/// Indicates whether any servers are currently trying to connect
1844+
/// </summary>
1845+
public bool IsConnecting
1846+
{
1847+
get
1848+
{
1849+
var tmp = serverSnapshot;
1850+
for (int i = 0; i < tmp.Length; i++)
1851+
if (tmp[i].IsConnecting) return true;
1852+
return false;
1853+
}
1854+
}
1855+
18421856
internal ConfigurationOptions RawConfig => configuration;
18431857

18441858
internal ServerSelectionStrategy ServerSelectionStrategy => serverSelectionStrategy;

StackExchange.Redis/StackExchange/Redis/Interfaces/IConnectionMultiplexer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public interface IConnectionMultiplexer
5151
/// </summary>
5252
bool IsConnected { get; }
5353

54+
/// <summary>
55+
/// Indicates whether any servers are connected
56+
/// </summary>
57+
bool IsConnecting { get; }
58+
5459
/// <summary>
5560
/// Should exceptions include identifiable details? (key names, additional .Data annotations)
5661
/// </summary>

StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public enum State : byte
7070

7171
public bool IsConnected => state == (int)State.ConnectedEstablished;
7272

73+
public bool IsConnecting => state == (int)State.ConnectedEstablishing || state == (int)State.Connecting;
74+
7375
public ConnectionMultiplexer Multiplexer { get; }
7476

7577
public ServerEndPoint ServerEndPoint { get; }

StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public ServerEndPoint(ConnectionMultiplexer multiplexer, EndPoint endpoint, Text
7777

7878
public bool IsConnected => interactive?.IsConnected == true;
7979

80+
public bool IsConnecting => interactive?.IsConnecting == true;
81+
8082
internal Exception LastException
8183
{
8284
get

0 commit comments

Comments
 (0)