コード例 #1
0
 private static bool CheckForSessionExpiredError(this RpcException rpcException, Func <Session> sessionFunc)
 {
     if (rpcException.IsSessionExpiredError())
     {
         SessionPool.MarkSessionExpired(sessionFunc());
     }
     return(false);
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }