Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Apr 9, 2024
1 parent 006beea commit d5f6d43
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ CancellationTokenSource cancellationTokenSource = new CancellationTokenSource()
Evict the Connection
--------------------

For the open connection, call the `PreventFromReturningToPool()` to make the connection not return to the pool.
For the open connection, call the `PreventPooling()` to make the connection not return to the pool.
The busy sessions counter will be decreased when the connection is closed.

Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task TestPreventConnectionFromReturningToPool()
Assert.AreEqual(1, pool.GetCurrentPoolSize());

// act
connection.PreventFromReturningToPool();
connection.PreventPooling();
await connection.CloseAsync(CancellationToken.None).ConfigureAwait(false);

// assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public void TestPreventConnectionFromReturningToPool()
Assert.AreEqual(1, pool.GetCurrentPoolSize());

// act
connection.PreventFromReturningToPool();
connection.PreventPooling();
connection.Close();

// assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void TestFailWhenPreventingFromReturningToPoolNotOpenedConnection()
var connection = new SnowflakeDbConnection(ConnectionString);

// act
var thrown = Assert.Throws<Exception>(() => connection.PreventFromReturningToPool());
var thrown = Assert.Throws<Exception>(() => connection.PreventPooling());

// assert
Assert.That(thrown.Message, Does.Contain("Connection is not ready to prevent its session from returning to the pool"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void TestPreventConnectionFromReturningToPool()
Assert.AreEqual(0, pool.GetCurrentPoolSize());

// act
connection.PreventFromReturningToPool();
connection.PreventPooling();
connection.Close();

// assert
Expand Down
6 changes: 3 additions & 3 deletions Snowflake.Data/Client/SnowflakeDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public override string DataSource
public override ConnectionState State => _connectionState;
internal SnowflakeDbTransaction ExplicitTransaction { get; set; } // tracks only explicit transaction operations

public void PreventFromReturningToPool()
public void PreventPooling()
{
if (SfSession == null)
{
throw new Exception("Connection is not ready to prevent its session from returning to the pool");
throw new Exception("Session not yet created for this connection. Unable to prevent the session from pooling");
}
SfSession.SetPooling(false);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ public override void Close()
}
_connectionState = ConnectionState.Closed;
}

#if NETCOREAPP3_0_OR_GREATER
// CloseAsync was added to IDbConnection as part of .NET Standard 2.1, first supported by .NET Core 3.0.
// Adding an override for CloseAsync will prevent the need for casting to SnowflakeDbConnection to call CloseAsync(CancellationToken).
Expand Down

0 comments on commit d5f6d43

Please sign in to comment.