Exemple #1
0
            private void HandOver(SubstreamHandler handler)
            {
                if (IsClosed(_stage._out))
                {
                    CompleteStage();
                }
                else
                {
                    _substreamSource = new SubSourceOutlet <T>(this, "SplitSource");
                    _substreamSource.SetHandler(handler);
                    _substreamCancelled = false;
                    SetHandler(_stage._in, handler);
                    SetKeepGoing(handler.HasInitialElement);

                    if (IsAvailable(_stage._out))
                    {
                        Push(_stage._out, Source.FromGraph(_substreamSource.Source));
                        ScheduleOnce(SubscriptionTimer, _timeout);
                        _substreamPushed = true;
                    }
                    else
                    {
                        _substreamPushed = false;
                    }
                }
            }
Exemple #2
0
        protected SubSourceOutlet <TIn> CreateSubOutlet(Inlet <TIn> inlet)
        {
            var sourceOut = new SubSourceOutlet <TIn>(this, $"RestartWithBackoff{_name}.subOut");

            sourceOut.SetHandler(new LambdaOutHandler(
                                     onPull: () =>
            {
                if (IsAvailable(In))
                {
                    sourceOut.Push(Grab(In));
                }
                else
                {
                    if (!HasBeenPulled(In))
                    {
                        Pull(In);
                    }
                }
            },
                                     onDownstreamFinish: () =>
            {
                if (_finishing || MaxRestartsReached() || _onlyOnFailures)
                {
                    Cancel(In);
                }
                else
                {
                    Log.Debug("Graph in finished");
                    ScheduleRestartTimer();
                }
            }
                                     ));

            SetHandler(In,
                       onPush: () =>
            {
                if (sourceOut.IsAvailable)
                {
                    sourceOut.Push(Grab(In));
                }
            },
                       onUpstreamFinish: () =>
            {
                _finishing = true;
                sourceOut.Complete();
            },
                       onUpstreamFailure: ex =>
            {
                _finishing = true;
                sourceOut.Fail(ex);
            });

            return(sourceOut);
        }
Exemple #3
0
            private Source <T, NotUsed> OpenSubstream()
            {
                var timeout = ActorMaterializer.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));
            }