Exemplo n.º 1
0
        private TransferPhase OpenSubstream(object element, object key)
        {
            return(new TransferPhase(PrimaryOutputs.NeedsDemandOrCancel, () =>
            {
                if (PrimaryOutputs.IsClosed)
                {
                    // Just drop, we do not open any more substreams
                    NextPhase(_waitNext);
                }
                else
                {
                    if (_keyToSubstreamOutput.Count == _maxSubstreams)
                    {
                        throw new IllegalStateException($"Cannot open substream for key '{key}': too many substreams open");
                    }
                    var substreamOutput = CreateSubstreamOutput();
                    var substreamFlow = Source.FromPublisher(substreamOutput);
                    PrimaryOutputs.EnqueueOutputElement(substreamFlow);

                    if (_keyToSubstreamOutput.ContainsKey(key))
                    {
                        _keyToSubstreamOutput[key] = substreamOutput;
                    }
                    else
                    {
                        _keyToSubstreamOutput.Add(key, substreamOutput);
                    }

                    NextPhase(DispatchToSubstream(element, substreamOutput));
                }
            }));
        }
Exemplo n.º 2
0
        protected virtual void Fail(Exception e)
        {
            if (Settings.IsDebugLogging)
            {
                Log.Debug("Failed due to: {0}", e.Message);
            }

            PrimaryInputs.Cancel();
            PrimaryOutputs.Error(e);
            Context.Stop(Self);
        }
Exemplo n.º 3
0
 protected override void PostStop()
 {
     PrimaryInputs.Cancel();
     PrimaryOutputs.Error(new AbruptTerminationException(Self));
 }
Exemplo n.º 4
0
 public virtual void PumpFinished()
 {
     PrimaryInputs.Cancel();
     PrimaryOutputs.Complete();
     Context.Stop(Self);
 }