Пример #1
0
        internal async Task <ServerNode> GetCurrentSessionNode(RequestExecutor requestExecutor)
        {
            (int Index, ServerNode Node)result;

            switch (requestExecutor.Conventions.LoadBalanceBehavior)
            {
            case LoadBalanceBehavior.UseSessionContext:
                if (_canUseLoadBalanceBehavior)
                {
                    result = await requestExecutor.GetNodeBySessionId(SessionId).ConfigureAwait(false);

                    return(result.Node);
                }
                break;
            }

            switch (requestExecutor.Conventions.ReadBalanceBehavior)
            {
            case ReadBalanceBehavior.None:
                result = await requestExecutor.GetPreferredNode().ConfigureAwait(false);

                break;

            case ReadBalanceBehavior.RoundRobin:
                result = await requestExecutor.GetNodeBySessionId(SessionId).ConfigureAwait(false);

                break;

            case ReadBalanceBehavior.FastestNode:
                result = await requestExecutor.GetFastestNode().ConfigureAwait(false);

                break;

            default:
                throw new ArgumentOutOfRangeException(requestExecutor.Conventions.ReadBalanceBehavior.ToString());
            }

            return(result.Node);
        }