public void Post(DataFlowToken token) { this.Init(); var wasQueued = this.StartBlock.Post(token); if (!wasQueued) { throw new InvalidFlowException("Message not accepted by the flow. Probably token send after flow is completed."); } }
public async Task PostToFlowAsync(DataFlowToken token) { if (this._flow == null) { var builder = new FlowModelBuilder(this._blockFactory); this._flowFactory(builder); this._flow = builder.BuildFlow(); } this._flow.Post(token); await this._flow.GetCompletionTask(); }
private IEnumerable <DataFlowToken> TransformInternal(DataFlowToken token) { Stopwatch perfCount = new Stopwatch(); try { perfCount.Start(); if (token.HasTerminated) { this.OnTerminatedTokenReceived?.Invoke(this, new TerminatedTokenReceivedEventArgs(token)); // just pass token to the next block - ignore processing of current block // we want to pass for instance to the end block that will process results return(this.PrepareResult(new[] { token })); } try { return(this.PrepareResult(this.Transform(token))); } catch (Exception ex) { token.HasTerminated = true; this.FlowLogger.Error(token, ex); this._flowExceptionManager.IncrementExceptionCount(); if (this._flowExceptionManager.IsCritical(ex) || this._flowExceptionManager.IsExceptionCountExceeded()) { this._cancellationTokenSource.Cancel(); throw; } return(this.PrepareResult(new[] { token })); } } finally { perfCount.Stop(); PerformanceMonitor.RegisterExecution(this.GetType().Name, perfCount.ElapsedTicks); } }
public abstract IEnumerable <DataFlowToken> Transform(DataFlowToken token);
/// <inheritdoc cref="IDataFlowLogger"/> public void Warn(DataFlowToken token, string formatter, params object[] arguments) { this._currentBlockLogger.Warn(string.Concat(token.TokenId, " ", formatter), arguments); }
/// <inheritdoc cref="IDataFlowLogger"/> public void Error(DataFlowToken token, Exception exception, string message) { this._currentBlockLogger.Error(exception, string.Concat(token.TokenId, " ", message)); }
/// <inheritdoc cref="IDataFlowLogger"/> public void Error(DataFlowToken token, Exception exception) { this._currentBlockLogger.Error(exception, token.TokenId.ToString()); }