/// <summary> /// TBD /// </summary> /// <param name="shape">TBD</param> /// <param name="attributes">TBD</param> /// <param name="stage">TBD</param> public PushPullGraphLogic( FlowShape <TIn, TOut> shape, Attributes attributes, AbstractStage <TIn, TOut> stage) : base(shape) { Attributes = attributes; _currentStage = Stage = stage; _shape = shape; SetHandler(_shape.Inlet, onPush: () => { try { _currentStage.OnPush(Grab(_shape.Inlet), Context); } catch (Exception e) { OnSupervision(e); } }, onUpstreamFailure: exception => _currentStage.OnUpstreamFailure(exception, Context), onUpstreamFinish: () => _currentStage.OnUpstreamFinish(Context)); SetHandler(_shape.Outlet, onPull: () => _currentStage.OnPull(Context), onDownstreamFinish: () => _currentStage.OnDownstreamFinish(Context)); }
private void OnSupervision(Exception exception) { var decision = _currentStage.Decide(exception); switch (decision) { case Directive.Stop: FailStage(exception); break; case Directive.Resume: ResetAfterSupervise(); break; case Directive.Restart: ResetAfterSupervise(); _currentStage.PostStop(); _currentStage = (AbstractStage <TIn, TOut>)_currentStage.Restart(); _currentStage.PreStart(Context); break; default: throw new NotSupportedException($"PushPullGraphLogic doesn't support supervision directive {decision}"); } }