Example #1
0
        internal static bool PinChannelSourceAndChannelIfRequired(
            IChannelSourceHandle channelSource,
            IChannelHandle channel,
            ICoreSessionHandle session,
            out IChannelSourceHandle pinnedChannelSource,
            out IChannelHandle pinnedChannel)
        {
            if (IsInLoadBalancedMode(channel.ConnectionDescription))
            {
                var server = channelSource.Server;

                pinnedChannelSource = new ChannelSourceHandle(
                    new ChannelChannelSource(
                        server,
                        channel.Fork(),
                        session.Fork()));

                if (session.IsInTransaction && !IsChannelPinned(session.CurrentTransaction))
                {
                    session.CurrentTransaction.PinChannel(channel.Fork());
                    session.CurrentTransaction.PinnedServer = server;
                }

                pinnedChannel = channel.Fork();

                return(true);
            }

            pinnedChannelSource = null;
            pinnedChannel       = null;
            return(false);
        }
 internal static void PinChannellIfRequired(
     IChannelSourceHandle channelSource,
     IChannelHandle channel,
     ICoreSessionHandle session)
 {
     if (IsInLoadBalancedMode(channel.ConnectionDescription) &&
         session.IsInTransaction &&
         !IsChannelPinned(session.CurrentTransaction))
     {
         if (channel.Connection is ICheckOutReasonTracker checkOutReasonTracker)
         {
             checkOutReasonTracker.SetCheckOutReasonIfNotAlreadySet(CheckOutReason.Transaction);
         }
         session.CurrentTransaction.PinChannel(channel.Fork());
         session.CurrentTransaction.PinnedServer = channelSource.Server;
     }
 }
        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));
        }
 public Task <IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
 {
     ThrowIfDisposed();
     return(Task.FromResult(_channel.Fork()));
 }
Example #5
0
 // private methods
 private IChannelSourceHandle GetChannelSourceHelper()
 {
     return(new ChannelSourceHandle(new ChannelChannelSource(_server, _channel.Fork(), _session.Fork())));
 }
Example #6
0
 private IChannelHandle GetChannelHelper()
 {
     return(_channel.Fork());
 }
Example #7
0
 private Task <IChannelSourceHandle> GetChannelSourceAsync(CancellationToken cancellationToken)
 {
     ThrowIfDisposed();
     return(Task.FromResult <IChannelSourceHandle>(new ChannelSourceHandle(new ChannelChannelSource(_server, _channel.Fork()))));
 }