예제 #1
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override IPublisher <TOut> Create(MaterializationContext context, out IActorRef materializer)
        {
            var mat = ActorMaterializerHelper.Downcast(context.Materializer);

            materializer = mat.ActorOf(context, ActorRefSourceActor <TOut> .Props(_bufferSize, _overflowStrategy, mat.Settings));
            return(new ActorPublisherImpl <TOut>(materializer));
        }
예제 #2
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out IActorRef materializer)
        {
            var subscriberRef = ActorMaterializerHelper.Downcast(context.Materializer).ActorOf(context, _props);

            materializer = subscriberRef;
            return(ActorSubscriber.Create <TIn>(subscriberRef));
        }
예제 #3
0
            protected internal override void OnTimer(object timerKey)
            {
                var materializer    = ActorMaterializerHelper.Downcast(Interpreter.Materializer);
                var timeoutSettings = materializer.Settings.SubscriptionTimeoutSettings;
                var timeout         = timeoutSettings.Timeout;

                switch (timeoutSettings.Mode)
                {
                case StreamSubscriptionTimeoutTerminationMode.NoopTermination:
                    //do nothing
                    break;

                case StreamSubscriptionTimeoutTerminationMode.WarnTermination:
                    materializer.Logger.Warning(
                        $"Substream subscription timeout triggered after {timeout} in prefixAndTail({_stage._count}).");
                    break;

                case StreamSubscriptionTimeoutTerminationMode.CancelTermination:
                    _tailSource.Timeout(timeout);
                    if (_tailSource.IsClosed)
                    {
                        CompleteStage();
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
예제 #4
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override IPublisher <TOut> Create(MaterializationContext context, out IActorRef materializer)
        {
            var publisherRef = ActorMaterializerHelper.Downcast(context.Materializer).ActorOf(context, _props);

            materializer = publisherRef;
            return(new ActorPublisherImpl <TOut>(publisherRef));
        }
예제 #5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="task">TBD</param>
        /// <returns>TBD</returns>
        public override IPublisher <ByteString> Create(MaterializationContext context, out Task <IOResult> task)
        {
            var materializer    = ActorMaterializerHelper.Downcast(context.Materializer);
            var ioResultPromise = new TaskCompletionSource <IOResult>();
            IPublisher <ByteString> pub;

            try
            {
                // can throw, i.e. FileNotFound
                var inputStream = _createInputStream();
                var props       = InputStreamPublisher
                                  .Props(inputStream, ioResultPromise, _chunkSize)
                                  .WithDispatcher(context
                                                  .EffectiveAttributes
                                                  .GetMandatoryAttribute <ActorAttributes.Dispatcher>()
                                                  .Name);
                var actorRef = materializer.ActorOf(context, props);
                pub = new ActorPublisherImpl <ByteString>(actorRef);
            }
            catch (Exception ex)
            {
                ioResultPromise.TrySetException(ex);
                pub = new ErrorPublisher <ByteString>(ex, Attributes.GetNameOrDefault("inputStreamSource"));
            }

            task = ioResultPromise.Task;
            return(pub);
        }
예제 #6
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out NotUsed materializer)
        {
            var actorMaterializer = ActorMaterializerHelper.Downcast(context.Materializer);
            var effectiveSettings = actorMaterializer.EffectiveSettings(context.EffectiveAttributes);
            var subscriberRef     = actorMaterializer.ActorOf(context,
                                                              ActorRefSinkActor.Props(_ref, effectiveSettings.MaxInputBufferSize, _onCompleteMessage));

            materializer = null;
            return(new ActorSubscriberImpl <TIn>(subscriberRef));
        }
예제 #7
0
            private Source <T, NotUsed> OpenSubstream()
            {
                var timeout = ActorMaterializerHelper.Downcast(Interpreter.Materializer).Settings.SubscriptionTimeoutSettings.Timeout;

                _tailSource = new SubSourceOutlet <T>(this, "TailSource");
                _tailSource.SetHandler(_subHandler);
                SetKeepGoing(true);
                ScheduleOnce(SubscriptionTimer, timeout);
                _builder = null;
                return(Source.FromGraph(_tailSource.Source));
            }
예제 #8
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out IPublisher <TIn> materializer)
        {
            var actorMaterializer = ActorMaterializerHelper.Downcast(context.Materializer);
            var settings          = actorMaterializer.EffectiveSettings(Attributes);
            var impl            = actorMaterializer.ActorOf(context, FanoutProcessorImpl <TIn, TStreamBuffer> .Props(settings, _onTerminated));
            var fanoutProcessor = new ActorProcessor <TIn, TIn>(impl);

            impl.Tell(new ExposedPublisher(fanoutProcessor));
            // Resolve cyclic dependency with actor. This MUST be the first message no matter what.
            materializer = fanoutProcessor;
            return(fanoutProcessor);
        }
예제 #9
0
파일: IOSinks.cs 프로젝트: ziez/akka.net
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out Task <IOResult> materializer)
        {
            var mat             = ActorMaterializerHelper.Downcast(context.Materializer);
            var settings        = mat.EffectiveSettings(context.EffectiveAttributes);
            var ioResultPromise = new TaskCompletionSource <IOResult>();

            var os       = _createOutput();
            var props    = OutputStreamSubscriber.Props(os, ioResultPromise, settings.MaxInputBufferSize, _autoFlush);
            var actorRef = mat.ActorOf(context, props);

            materializer = ioResultPromise.Task;
            return(new ActorSubscriberImpl <ByteString>(actorRef));
        }
예제 #10
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="task">TBD</param>
        /// <returns>TBD</returns>
        public override IPublisher <ByteString> Create(MaterializationContext context, out Task <IOResult> task)
        {
            // FIXME rewrite to be based on GraphStage rather than dangerous downcasts
            var materializer = ActorMaterializerHelper.Downcast(context.Materializer);
            var settings     = materializer.EffectiveSettings(context.EffectiveAttributes);

            var ioResultPromise = new TaskCompletionSource <IOResult>();
            var props           = FilePublisher.Props(_f, ioResultPromise, _chunkSize, settings.InitialInputBufferSize, settings.MaxInputBufferSize);
            var dispatcher      = context.EffectiveAttributes.GetAttribute(DefaultAttributes.IODispatcher.GetAttribute <ActorAttributes.Dispatcher>());
            var actorRef        = materializer.ActorOf(context, props.WithDispatcher(dispatcher.Name));

            task = ioResultPromise.Task;
            return(new ActorPublisherImpl <ByteString>(actorRef));
        }
예제 #11
0
파일: IOSinks.cs 프로젝트: ziez/akka.net
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out Task <IOResult> materializer)
        {
            var mat      = ActorMaterializerHelper.Downcast(context.Materializer);
            var settings = mat.EffectiveSettings(context.EffectiveAttributes);

            var ioResultPromise = new TaskCompletionSource <IOResult>();
            var props           = FileSubscriber.Props(_f, ioResultPromise, settings.MaxInputBufferSize, _fileMode);
            var dispatcher      = context.EffectiveAttributes.GetAttribute(DefaultAttributes.IODispatcher.AttributeList.First()) as ActorAttributes.Dispatcher;

            var actorRef = mat.ActorOf(context, props.WithDispatcher(dispatcher.Name));

            materializer = ioResultPromise.Task;
            return(new ActorSubscriberImpl <ByteString>(actorRef));
        }
예제 #12
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="materializer">TBD</param>
        /// <returns>TBD</returns>
        public override object Create(MaterializationContext context, out Task <IOResult> materializer)
        {
            var mat      = ActorMaterializerHelper.Downcast(context.Materializer);
            var settings = mat.EffectiveSettings(context.EffectiveAttributes);

            var ioResultPromise = new TaskCompletionSource <IOResult>();
            var props           = FileSubscriber.Props(_f, ioResultPromise, settings.MaxInputBufferSize, _startPosition, _fileMode, _autoFlush, _flushSignaler);

            var actorRef = mat.ActorOf(
                context,
                props.WithDispatcher(context
                                     .EffectiveAttributes
                                     .GetMandatoryAttribute <ActorAttributes.Dispatcher>()
                                     .Name));

            materializer = ioResultPromise.Task;
            return(new ActorSubscriberImpl <ByteString>(actorRef));
        }
예제 #13
0
 public override void PreStart()
 {
     _dispatcher = ActorMaterializerHelper.Downcast(Materializer).System.Dispatchers.Lookup(_dispatcherId);
     base.PreStart();
 }
예제 #14
0
            public override void PreStart()
            {
                var settings = ActorMaterializerHelper.Downcast(Interpreter.Materializer).Settings;

                _timeout = settings.SubscriptionTimeoutSettings.Timeout;
            }