Ejemplo n.º 1
0
        internal void AddMeasurement(IIncomingStep step, TimeSpan elapsed)
        {
            var correctedElapsed = Correct(elapsed);
            var stepType         = step.GetType();

            var measurement = new Measurement(stepType, correctedElapsed);

            _measurements.Push(measurement);
        }
Ejemplo n.º 2
0
        internal void AddMeasurement(IIncomingStep step, TimeSpan elapsed)
        {
            var correctedElapsed = Correct(elapsed);
            var stepType = step.GetType();

            var measurement = new Measurement(stepType, correctedElapsed);

            _measurements.Push(measurement);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Configures injection of the given <see cref="IIncomingStep"/>, positioning it relative to another step
        /// specified by <paramref name="anchorStep"/>. The relative position is specified with either
        /// <see cref="PipelineRelativePosition.Before"/> or <see cref="PipelineRelativePosition.After"/>
        /// </summary>
        public PipelineStepInjector OnReceive(IIncomingStep step, PipelineRelativePosition position, Type anchorStep)
        {
            if (step == null) throw new ArgumentNullException(nameof(step));
            if (anchorStep == null) throw new ArgumentNullException(nameof(anchorStep));

            _incomingInjectedSteps
                .GetOrAdd(anchorStep, _ => new List<Tuple<PipelineRelativePosition, IIncomingStep>>())
                .Add(Tuple.Create(position, step));

            return this;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the specified receive <paramref name="step"/> to be concatenated at the position specified by <paramref name="position"/>
 /// </summary>
 public PipelineStepConcatenator OnReceive(IIncomingStep step, PipelineAbsolutePosition position)
 {
     if (position == PipelineAbsolutePosition.Front)
     {
         _incomingFrontSteps.Add(step);
     }
     else
     {
         _incomingBackSteps.Add(step);
     }
     return this;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the specified receive <paramref name="step"/> to be concatenated at the position specified by <paramref name="position"/>
 /// </summary>
 public PipelineStepConcatenator OnReceive(IIncomingStep step, PipelineAbsolutePosition position)
 {
     if (position == PipelineAbsolutePosition.Front)
     {
         _incomingFrontSteps.Add(step);
     }
     else
     {
         _incomingBackSteps.Add(step);
     }
     return(this);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sets the specified receive <paramref name="step"/> to be concatenated at the position specified by <paramref name="position"/>
 /// </summary>
 public PipelineStepConcatenator OnReceive(IIncomingStep step, PipelineAbsolutePosition position)
 {
     if (step == null) throw new ArgumentNullException(nameof(step));
     if (position == PipelineAbsolutePosition.Front)
     {
         _incomingFrontSteps.Add(step);
     }
     else
     {
         _incomingBackSteps.Add(step);
     }
     return this;
 }
Ejemplo n.º 7
0
        public static OptionsConfigurer RegisterIncomingStep(this OptionsConfigurer configurer,
                                                             IIncomingStep stepToInject,
                                                             PipelineRelativePosition position = PipelineRelativePosition.Before,
                                                             Type anchorStep = null)
        {
            anchorStep = anchorStep ?? typeof(DispatchIncomingMessageStep);
            configurer.Decorate <IPipeline>(c =>
            {
                var pipeline = c.Get <IPipeline>();

                return(new PipelineStepInjector(pipeline)
                       .OnReceive(stepToInject, position, anchorStep));
            });

            return(configurer);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the specified receive <paramref name="step"/> to be concatenated at the position specified by <paramref name="position"/>
 /// </summary>
 public PipelineStepConcatenator OnReceive(IIncomingStep step, PipelineAbsolutePosition position)
 {
     if (step == null)
     {
         throw new ArgumentNullException(nameof(step));
     }
     if (position == PipelineAbsolutePosition.Front)
     {
         _incomingFrontSteps.Add(step);
     }
     else
     {
         _incomingBackSteps.Add(step);
     }
     return(this);
 }
Ejemplo n.º 9
0
        static void AddRebusWithStep(IServiceCollection serviceCollection, IIncomingStep step)
        {
            serviceCollection.AddRebus(configure => configure
                                       .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "whatever"))
                                       .Options(o =>
            {
                o.Decorate <IPipeline>(c =>
                {
                    var pipeline = c.Get <IPipeline>();
                    return(new PipelineStepInjector(pipeline)
                           .OnReceive(step, PipelineRelativePosition.After, typeof(SimpleRetryStrategyStep)));
                });

                o.LogPipeline(verbose: true);
            }));
        }
Ejemplo n.º 10
0
        public async Task TakeTime(IIncomingStep step)
        {
            const int count = 1000000;
            //const int count = 1000;

            var stopwatch = Stopwatch.StartNew();

            await Task.WhenAll(Enumerable.Range(0, count).Select(GetIncomingStepContext)
                               .Select(context => step.Process(context, Noop)));

            var elapsed = stopwatch.Elapsed;

            Console.WriteLine($@"
Step: {step}
Invocations: {count}
Elapsed: {elapsed.TotalSeconds:0.0}
");
        }
Ejemplo n.º 11
0
 public ProfilerStep(IIncomingStep nextStep)
 {
     _nextStep = nextStep;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds a new incoming step to the receive pipeline
 /// </summary>
 public DefaultPipeline OnReceive(IIncomingStep step)
 {
     _receiveSteps.Add(step);
     return this;
 }
Ejemplo n.º 13
0
 public StatsContextDisposable(StatsContext statsContext, IIncomingStep nextStep)
 {
     _statsContext = statsContext;
     _nextStep     = nextStep;
 }
Ejemplo n.º 14
0
 internal IDisposable Measure(IIncomingStep nextStep)
 {
     return(new StatsContextDisposable(this, nextStep));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Adds a new incoming step to the receive pipeline
 /// </summary>
 public DefaultPipeline OnReceive(IIncomingStep step)
 {
     _receiveSteps.Add(step);
     return(this);
 }
Ejemplo n.º 16
0
 public StatsContextDisposable(StatsContext statsContext, IIncomingStep nextStep)
 {
     _statsContext = statsContext;
     _nextStep = nextStep;
 }
Ejemplo n.º 17
0
 bool HasMatch(IIncomingStep step)
 {
     return(_incomingStepPredicates.Any(p => p(step)));
 }
Ejemplo n.º 18
0
 internal IDisposable Measure(IIncomingStep nextStep) => new StatsContextDisposable(this, nextStep);
Ejemplo n.º 19
0
        /// <summary>
        /// Configures injection of the given <see cref="IIncomingStep"/>, positioning it relative to another step
        /// specified by <paramref name="anchorStep"/>. The relative position is specified with either
        /// <see cref="PipelineRelativePosition.Before"/> or <see cref="PipelineRelativePosition.After"/>
        /// </summary>
        public PipelineStepInjector OnReceive(IIncomingStep step, PipelineRelativePosition position, Type anchorStep)
        {
            if (step == null) throw new ArgumentNullException("step");
            if (anchorStep == null) throw new ArgumentNullException("anchorStep");

            _incomingInjectedSteps
                .GetOrAdd(anchorStep, _ => new List<Tuple<PipelineRelativePosition, IIncomingStep>>())
                .Add(Tuple.Create(position, step));

            return this;
        }
Ejemplo n.º 20
0
 internal IDisposable Measure(IIncomingStep nextStep)
 {
     return new StatsContextDisposable(this, nextStep);
 }
Ejemplo n.º 21
0
 bool HasMatch(IIncomingStep step)
 {
     return _incomingStepPredicates.Any(p => p(step));
 }
Ejemplo n.º 22
0
 public ProfilerStep(IIncomingStep nextStep)
 {
     _nextStep = nextStep;
 }
Ejemplo n.º 23
0
        public IncomingPipeline Register(IIncomingStep step)
        {
            registeredSteps.Enqueue(step);

            return this;
        }