示例#1
0
        internal static IChannelSourceHandle CreateGetMoreChannelSource(IChannelSourceHandle channelSource, long cursorId)
        {
            IChannelSource effectiveChannelSource;

            if (IsInLoadBalancedMode(channelSource.ServerDescription) && cursorId != 0)
            {
                var getMoreChannel = channelSource.GetChannel(CancellationToken.None); // no need for cancellation token since we already have channel in the source
                var getMoreSession = channelSource.Session.Fork();

                effectiveChannelSource = new ChannelChannelSource(
                    channelSource.Server,
                    getMoreChannel,
                    getMoreSession);
            }
            else
            {
                effectiveChannelSource = new ServerChannelSource(channelSource.Server, channelSource.Session.Fork());
            }

            return(new ChannelSourceHandle(effectiveChannelSource));
        }
        internal static IChannelSourceHandle CreateGetMoreChannelSource(IChannelSourceHandle channelSource, IChannelHandle channel, long cursorId)
        {
            IChannelSource effectiveChannelSource;

            if (IsInLoadBalancedMode(channelSource.ServerDescription) && cursorId != 0)
            {
                if (channel.Connection is ICheckOutReasonTracker checkOutReasonTracker)
                {
                    checkOutReasonTracker.SetCheckOutReasonIfNotAlreadySet(CheckOutReason.Cursor);
                }

                effectiveChannelSource = new ChannelChannelSource(
                    channelSource.Server,
                    channel.Fork(),
                    channelSource.Session.Fork());
            }
            else
            {
                effectiveChannelSource = new ServerChannelSource(channelSource.Server, channelSource.Session.Fork());
            }

            return(new ChannelSourceHandle(effectiveChannelSource));
        }