Пример #1
0
 protected bool WaitingExposedPublisher(object message)
 {
     if (message is ExposedPublisher)
     {
         ExposedPublisher = ((ExposedPublisher)message).Publisher;
         SubReceive.Become(DownstreamRunning);
         return(true);
     }
     throw new IllegalStateException(
               $"The first message must be [{typeof (ExposedPublisher)}] but was [{message}]");
 }
Пример #2
0
        protected virtual void OnSubscribe(ISubscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentException("OnSubscribe require subscription not to be null");
            }

            if (_isUpstreamCompleted)
            {
                subscription.Cancel();
            }
            else
            {
                _upstream = subscription;
                // prefetch
                _upstream.Request(_inputBuffer.Length);
                SubReceive.Become(UpstreamRunning);
            }

            Pump.GotUpstreamSubscription();
        }
Пример #3
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="maxBufferSize">TBD</param>
        /// <param name="initialBufferSize">TBD</param>
        /// <param name="self">TBD</param>
        /// <param name="pump">TBD</param>
        /// <param name="afterShutdown">TBD</param>
        /// <exception cref="IllegalStateException">
        /// This exception is thrown when the first message isn't of type <see cref="ExposedPublisher"/>.
        /// </exception>
        public FanoutOutputs(int maxBufferSize, int initialBufferSize, IActorRef self, IPump pump, Action afterShutdown = null)
        {
            _self               = self;
            _pump               = pump;
            _afterShutdown      = afterShutdown;
            MaxBufferSize       = maxBufferSize;
            InitialBufferSize   = initialBufferSize;
            NeedsDemand         = DefaultOutputTransferStates.NeedsDemand(this);
            NeedsDemandOrCancel = DefaultOutputTransferStates.NeedsDemandOrCancel(this);
            SubReceive          = new SubReceive(message =>
            {
                if (!(message is ExposedPublisher publisher))
                {
                    throw new IllegalStateException($"The first message must be ExposedPublisher but was {message}");
                }

                ExposedPublisher = publisher.Publisher;
                SubReceive.Become(DownstreamRunning);
                return(true);
            });
        }
Пример #4
0
 protected virtual void OnError(Exception e)
 {
     _isUpstreamCompleted = true;
     SubReceive.Become(Completed);
     InputOnError(e);
 }
Пример #5
0
 protected virtual void OnComplete()
 {
     _isUpstreamCompleted = true;
     SubReceive.Become(Completed);
     Pump.Pump();
 }