Skip to content

Commit 86a9e31

Browse files
committed
Rename InOrder to FailOver.
While not a load balancing technique, "FailOver" is the more common term for always trying the first server and only trying the second server if the first fails.
1 parent 8be0773 commit 86a9e31

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

docs/content/connection-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ These are the other options that MySqlConnector supports. They are set to sensib
199199
<dl>
200200
<dt>RoundRobin</dt>
201201
<dd>Each new connection opened for this connection pool uses the next host name (sequentially with wraparound). Requires <code>Pooling=True</code>. This is the default if <code>Pooling=True</code>.</dd>
202-
<dt>InOrder</dt>
203-
<dd>Each new connection tries the hosts in order, starting with the first one. This is the default if <code>Pooling=False</code>.</dd>
202+
<dt>FailOver</dt>
203+
<dd>Each new connection tries to connect to the first host; subsequent hosts are used only if connecting to the first one fails. This is the default if <code>Pooling=False</code>.</dd>
204204
<dt>Random</dt>
205205
<dd>Servers are tried in a random order.</dd>
206206
<dt>LeastConnections</dt>

docs/content/tutorials/migrating-from-connector-net.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ MySqlConnector has some different default connection string options:
3838
<tr>
3939
<td><code>LoadBalance</code></td>
4040
<td>Default is <code>RoundRobin</code></td>
41-
<td>(not configurable, effective default is <code>InOrder</code>)</td>
41+
<td>(not configurable, effective default is <code>FailOver</code>)</td>
4242
<td>Connector/NET currently has <a href="https://bugs.mysql.com/bug.php?id=81650" title="MySQL bug #81650">a bug</a> that prevents multiple host names being used.</td>
4343
</tr>
4444
<tr>

src/MySqlConnector/Core/ConnectionPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private ConnectionPool(ConnectionSettings cs)
351351
m_hostSessions[hostName] = 0;
352352
}
353353
m_loadBalancer = cs.ConnectionType != ConnectionType.Tcp ? null :
354-
cs.HostNames.Count == 1 || cs.LoadBalance == MySqlLoadBalance.InOrder ? InOrderLoadBalancer.Instance :
354+
cs.HostNames.Count == 1 || cs.LoadBalance == MySqlLoadBalance.FailOver ? FailOverLoadBalancer.Instance :
355355
cs.LoadBalance == MySqlLoadBalance.Random ? RandomLoadBalancer.Instance :
356356
cs.LoadBalance == MySqlLoadBalance.LeastConnections ? new LeastConnectionsLoadBalancer(this) :
357357
(ILoadBalancer) new RoundRobinLoadBalancer();

src/MySqlConnector/Core/ILoadBalancer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ internal interface ILoadBalancer
1212
IEnumerable<string> LoadBalance(IReadOnlyList<string> hosts);
1313
}
1414

15-
internal sealed class InOrderLoadBalancer : ILoadBalancer
15+
internal sealed class FailOverLoadBalancer : ILoadBalancer
1616
{
17-
public static ILoadBalancer Instance { get; } = new InOrderLoadBalancer();
17+
public static ILoadBalancer Instance { get; } = new FailOverLoadBalancer();
1818

1919
public IEnumerable<string> LoadBalance(IReadOnlyList<string> hosts) => hosts;
2020

21-
private InOrderLoadBalancer()
21+
private FailOverLoadBalancer()
2222
{
2323
}
2424
}

src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ private async Task<ServerSession> CreateSessionAsync(IOBehavior ioBehavior, Canc
357357
}
358358
else
359359
{
360-
// only "in order" and "random" load balancers supported without connection pooling
360+
// only "fail over" and "random" load balancers supported without connection pooling
361361
var loadBalancer = m_connectionSettings.LoadBalance == MySqlLoadBalance.Random && m_connectionSettings.HostNames.Count > 1 ?
362-
RandomLoadBalancer.Instance : InOrderLoadBalancer.Instance;
362+
RandomLoadBalancer.Instance : FailOverLoadBalancer.Instance;
363363

364364
var session = new ServerSession();
365365
await session.ConnectAsync(m_connectionSettings, loadBalancer, ioBehavior, linkedSource.Token).ConfigureAwait(false);

src/MySqlConnector/MySql.Data.MySqlClient/MySqlLoadBalance.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ namespace MySql.Data.MySqlClient
33
public enum MySqlLoadBalance
44
{
55
/// <summary>
6-
/// Servers are tried sequentially, across multiple calls to <see cref="MySqlConnection.Open"/>.
6+
/// Each new connection opened for a connection pool uses the next host name (sequentially with wraparound).
77
/// </summary>
88
RoundRobin,
99

1010
/// <summary>
11-
/// Servers are tried in order, starting with the first one, for each call to <see cref="MySqlConnection.Open"/>.
11+
/// Each new connection tries to connect to the first host; subsequent hosts are used only if connecting to the first one fails.
1212
/// </summary>
13-
InOrder,
13+
FailOver,
1414

1515
/// <summary>
1616
/// Servers are tried in random order.

tests/MySqlConnector.Tests/LoadBalancerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace MySqlConnector.Tests
77
public class LoadBalancerTests
88
{
99
[Fact]
10-
public void InOrder()
10+
public void FailOver()
1111
{
12-
var loadBalancer = InOrderLoadBalancer.Instance;
12+
var loadBalancer = FailOverLoadBalancer.Instance;
1313
var input = new[] { "a", "b", "c", "d" };
1414
Assert.Equal(new[] { "a", "b", "c", "d" }, loadBalancer.LoadBalance(input));
1515
Assert.Same(input, loadBalancer.LoadBalance(input));

0 commit comments

Comments
 (0)