private static bool CheckForSessionExpiredError(this RpcException rpcException, Func <Session> sessionFunc) { if (rpcException.IsSessionExpiredError()) { SessionPool.MarkSessionExpired(sessionFunc()); } return(false); }
public async Task ExpiredSessionsNotPooled() { using (var pool = new SessionPool()) { var client = new FakeClient(); var session = await CreateSessionAsync(pool, client); SessionPool.MarkSessionExpired(session); pool.ReleaseToPool(client, session); var session2 = await CreateSessionAsync(pool, client); Assert.NotSame(session, session2); Assert.Equal(2, client.Sessions.Count); } }
public async Task ExpiredSessionsNotPooled() { using (var pool = new SessionPool()) { var client = CreateMockClient(); var session = await pool.CreateSessionFromPoolAsync( client.Object, s_defaultName.ProjectId, s_defaultName.InstanceId, s_defaultName.DatabaseId, null, CancellationToken.None) .ConfigureAwait(false); SessionPool.MarkSessionExpired(session); pool.ReleaseToPool(client.Object, session); var session2 = await pool.CreateSessionFromPoolAsync( client.Object, s_defaultName.ProjectId, s_defaultName.InstanceId, s_defaultName.DatabaseId, null, CancellationToken.None) .ConfigureAwait(false); Assert.NotSame(session, session2); Assert.Equal(1, _createdSessions.Count); Assert.Equal(2, _createdSessions[client].Count); } }