-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-902611 removed singleton pattern from SessionPool; introduced ne…
…w interface for ConnectionManager; split tests of ConnectionPool and some cleanup in the classes
- Loading branch information
1 parent
127343f
commit ca04c5b
Showing
8 changed files
with
887 additions
and
813 deletions.
There are no files selected for viewing
361 changes: 361 additions & 0 deletions
361
Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolAsyncIT.cs
Large diffs are not rendered by default.
Oops, something went wrong.
411 changes: 411 additions & 0 deletions
411
Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolIT.cs
Large diffs are not rendered by default.
Oops, something went wrong.
775 changes: 0 additions & 775 deletions
775
Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
using Snowflake.Data.Client; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
class PoolConfig | ||
{ | ||
private readonly bool _pooling; | ||
private readonly long _timeout; | ||
private readonly int _maxPoolSize; | ||
|
||
public PoolConfig() | ||
{ | ||
_maxPoolSize = SnowflakeDbConnectionPool.GetMaxPoolSize(); | ||
_timeout = SnowflakeDbConnectionPool.GetTimeout(); | ||
_pooling = SnowflakeDbConnectionPool.GetPooling(); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
SnowflakeDbConnectionPool.SetMaxPoolSize(_maxPoolSize); | ||
SnowflakeDbConnectionPool.SetTimeout(_timeout); | ||
SnowflakeDbConnectionPool.SetPooling(_pooling); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Security; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Snowflake.Data.Core.Session | ||
{ | ||
internal sealed class ConnectionManagerV1 : IConnectionManager | ||
{ | ||
private readonly SessionPool _sessionPool = new SessionPool(); | ||
public SFSession GetSession(string connectionString, SecureString password) => _sessionPool.GetSession(connectionString, password); | ||
public Task<SFSession> GetSessionAsync(string connectionString, SecureString password, CancellationToken cancellationToken) | ||
=> _sessionPool.GetSessionAsync(connectionString, password, cancellationToken); | ||
public bool AddSession(SFSession session) => _sessionPool.AddSession(session); | ||
public void ClearAllPools() => _sessionPool.ClearAllPools(); | ||
public void SetMaxPoolSize(int maxPoolSize) => _sessionPool.SetMaxPoolSize(maxPoolSize); | ||
public int GetMaxPoolSize() => _sessionPool.GetMaxPoolSize(); | ||
public void SetTimeout(long connectionTimeout) => _sessionPool.SetTimeout(connectionTimeout); | ||
public long GetTimeout() => _sessionPool.GetTimeout(); | ||
public int GetCurrentPoolSize() => _sessionPool.GetCurrentPoolSize(); | ||
public bool SetPooling(bool poolingEnabled) => _sessionPool.SetPooling(poolingEnabled); | ||
public bool GetPooling() => _sessionPool.GetPooling(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
using System.Security; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Snowflake.Data.Core.Session | ||
{ | ||
public interface IConnectionManager | ||
{ | ||
SFSession GetSession(string connectionString, SecureString password); | ||
Task<SFSession> GetSessionAsync(string connectionString, SecureString password, CancellationToken cancellationToken); | ||
bool AddSession(SFSession session); | ||
void ClearAllPools(); | ||
void SetMaxPoolSize(int maxPoolSize); | ||
int GetMaxPoolSize(); | ||
void SetTimeout(long connectionTimeout); | ||
long GetTimeout(); | ||
int GetCurrentPoolSize(); | ||
bool SetPooling(bool poolingEnabled); | ||
bool GetPooling(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters