Skip to content

Commit

Permalink
SNOW-902608 Connection pool V2
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mhofman committed Oct 4, 2023
1 parent dd608f8 commit e3b540c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Snowflake.Data/Client/SnowflakeDbConnectionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using Snowflake.Data.Core;
using Snowflake.Data.Core.ConnectionPool;
using Snowflake.Data.Core.Session;
using Snowflake.Data.Log;

Expand Down Expand Up @@ -85,10 +86,12 @@ public static bool GetPooling()

private static ConnectionPoolManagerBase ProvideConnectionPoolManager()
{
if (s_poolVersion == PoolManagerVersion.Version1)
return new ConnectionPoolManagerV1();

throw new NotSupportedException("Pool version not supported");
switch (s_poolVersion)
{
case PoolManagerVersion.Version1: return new ConnectionPoolManagerV1();
case PoolManagerVersion.Version2: return new ConnectionPoolManagerV2();
default: throw new NotSupportedException("Pool version not supported");
}
}

internal static SFSession GetSession(string connectionString, SecureString password)
Expand Down
20 changes: 20 additions & 0 deletions Snowflake.Data/Core/Session/ConnectionPoolManagerV2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Snowflake.Data.Core.Session;

namespace Snowflake.Data.Core.ConnectionPool
{
class ConnectionPoolManagerV2 : ConnectionPoolManagerBase
{
private const bool AllowExceedMaxPoolSizeDefault = false;
// private const int MinPoolSizeDefault = 0; // TODO: SNOW-902610
private const int MaxPoolSizeDefault = 10;

protected override PoolManagerVersion GetVersion() => PoolManagerVersion.Version2;

protected override void ApplyPoolDefaults(SessionPool pool)
{
pool.SetAllowExceedMaxPoolSize(AllowExceedMaxPoolSizeDefault);
// pool.SetMinPoolSize(MinPoolSizeDefault); // TODO: SNOW-902610
pool.SetMaxPoolSize(MaxPoolSizeDefault);
}
}
}

0 comments on commit e3b540c

Please sign in to comment.