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.");
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 public abstract IEnumerable <DataFlowToken> Transform(DataFlowToken token);
Ejemplo n.º 5
0
 /// <inheritdoc cref="IDataFlowLogger"/>
 public void Warn(DataFlowToken token, string formatter, params object[] arguments)
 {
     this._currentBlockLogger.Warn(string.Concat(token.TokenId, " ", formatter), arguments);
 }
Ejemplo n.º 6
0
 /// <inheritdoc cref="IDataFlowLogger"/>
 public void Error(DataFlowToken token, Exception exception, string message)
 {
     this._currentBlockLogger.Error(exception, string.Concat(token.TokenId, " ", message));
 }
Ejemplo n.º 7
0
 /// <inheritdoc cref="IDataFlowLogger"/>
 public void Error(DataFlowToken token, Exception exception)
 {
     this._currentBlockLogger.Error(exception, token.TokenId.ToString());
 }