Skip to content

Commit 7663893

Browse files
revert on session pool
1 parent 1ac396f commit 7663893

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Ydb.Sdk/src/Ado/PoolManager.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System.Collections.Concurrent;
22
using Ydb.Sdk.Ado.Session;
3+
using Ydb.Sdk.Pool;
4+
using Ydb.Sdk.Services.Query;
35

46
namespace Ydb.Sdk.Ado;
57

68
internal static class PoolManager
79
{
810
private static readonly SemaphoreSlim SemaphoreSlim = new(1); // async mutex
9-
private static readonly ConcurrentDictionary<string, ISessionSource> Pools = new();
11+
private static readonly ConcurrentDictionary<string, SessionPool> Pools = new();
1012

1113
internal static async Task<ISession> GetSession(
1214
YdbConnectionStringBuilder settings,
@@ -15,7 +17,7 @@ CancellationToken cancellationToken
1517
{
1618
if (Pools.TryGetValue(settings.ConnectionString, out var sessionPool))
1719
{
18-
return await sessionPool.OpenSession(cancellationToken);
20+
return await sessionPool.GetSession(cancellationToken);
1921
}
2022

2123
try
@@ -24,16 +26,16 @@ CancellationToken cancellationToken
2426

2527
if (Pools.TryGetValue(settings.ConnectionString, out var pool))
2628
{
27-
return await pool.OpenSession(cancellationToken);
29+
return await pool.GetSession(cancellationToken);
2830
}
2931

30-
var newSessionPool = new PoolingSessionSource<PoolingSession>(
31-
await PoolingSessionFactory.Create(settings), settings
32+
var newSessionPool = new SessionPool(
33+
await settings.BuildDriver(), new SessionPoolConfig()
3234
);
3335

3436
Pools[settings.ConnectionString] = newSessionPool;
3537

36-
return await newSessionPool.OpenSession(cancellationToken);
38+
return await newSessionPool.GetSession(cancellationToken);
3739
}
3840
finally
3941
{

src/Ydb.Sdk/test/Ydb.Sdk.Ado.Tests/Session/PoolingSessionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ public async Task Delete_WhenSuccessOpenSession_IsBroken()
186186
_mockIDriver.Setup(driver => driver.UnaryCall(
187187
QueryService.DeleteSessionMethod,
188188
It.Is<DeleteSessionRequest>(request => request.SessionId.Equals(SessionId)),
189-
It.Is<GrpcRequestSettings>(grpcRequestSettings => grpcRequestSettings.NodeId == NodeId))
190-
);
189+
It.Is<GrpcRequestSettings>(grpcRequestSettings => grpcRequestSettings.NodeId == NodeId)
190+
)).ReturnsAsync(new DeleteSessionResponse { Status = StatusIds.Types.StatusCode.Success });
191191
Assert.False(session.IsBroken);
192192
await session.DeleteSession();
193193
Assert.True(session.IsBroken);
@@ -206,8 +206,8 @@ public async Task Delete_WhenSuccessOpenSessionBadSessionInAttachStream_IsBroken
206206
_mockIDriver.Setup(driver => driver.UnaryCall(
207207
QueryService.DeleteSessionMethod,
208208
It.Is<DeleteSessionRequest>(request => request.SessionId.Equals(SessionId)),
209-
It.Is<GrpcRequestSettings>(grpcRequestSettings => grpcRequestSettings.NodeId == NodeId))
210-
);
209+
It.Is<GrpcRequestSettings>(grpcRequestSettings => grpcRequestSettings.NodeId == NodeId)
210+
)).ReturnsAsync(new DeleteSessionResponse { Status = StatusIds.Types.StatusCode.Success });
211211
Assert.False(session.IsBroken);
212212
session.OnNotSuccessStatusCode(StatusCode.BadSession);
213213
await session.DeleteSession();

0 commit comments

Comments
 (0)