コード例 #1
0
 public ConsumerMessageHandlerMiddleware(IPipeBuilderFactory pipeBuilderFactory, IPipeContextFactory contextFactory, ConsumeOptions options = null)
 {
     ContextFactory         = contextFactory;
     ConsumeFunc            = options?.ConsumerFunc ?? (context => context.GetConsumer());
     ConsumePipe            = pipeBuilderFactory.Create(options?.Pipe ?? (builder => {}));
     ThrottledExecutionFunc = options?.ThrottleFuncFunc ?? (context => context.GetConsumeThrottleAction());
 }
コード例 #2
0
 public ResponseConsumeMiddleware(IConsumerFactory consumerFactory, IPipeBuilderFactory factory, ResponseConsumerOptions options)
 {
     ResponseConfigFunc    = options?.ResponseConfigFunc ?? (context => context.GetResponseConfiguration());
     CorrelationidFunc     = options?.CorrelationIdFunc ?? (context => context.GetBasicProperties()?.CorrelationId);
     DedicatedConsumerFunc = options?.UseDedicatedConsumer ?? (context => context.GetDedicatedResponseConsumer());
     ConsumerFactory       = consumerFactory;
     ResponsePipe          = factory.Create(options.ResponseReceived);
 }
コード例 #3
0
 public ResponseConsumeMiddleware(IConsumerFactory consumerFactory, IPipeBuilderFactory factory, ILogger <ResponseConsumeMiddleware> logger, ResponseConsumerOptions options)
 {
     ResponseConfigFunc    = options?.ResponseConfigFunc ?? (context => context.GetResponseConfiguration());
     CorrelationidFunc     = options?.CorrelationIdFunc ?? (context => context.GetBasicProperties()?.CorrelationId);
     DedicatedConsumerFunc = options?.UseDedicatedConsumer ?? (context => context.GetDedicatedResponseConsumer());
     ConsumerFactory       = consumerFactory ?? throw new ArgumentNullException(nameof(consumerFactory));
     Logger       = logger ?? throw new ArgumentNullException(nameof(logger));
     ResponsePipe = factory.Create(options.ResponseReceived);
 }
コード例 #4
0
        public async Task <IPipeContext> InvokeAsync(Action <IPipeBuilder> pipeCfg, Action <IPipeContext> contextCfg = null, CancellationToken token = default(CancellationToken))
        {
            var pipe    = _pipeBuilderFactory.Create(pipeCfg);
            var context = _contextFactory.CreateContext();

            contextCfg?.Invoke(context);
            await pipe.InvokeAsync(context, token);

            return(context);
        }
コード例 #5
0
 public ConsumerMessageHandlerMiddleware(
     IPipeBuilderFactory pipeBuilderFactory,
     IPipeContextFactory contextFactory,
     ILogger <ConsumerMessageHandlerMiddleware> logger,
     ConsumeOptions options = null)
 {
     ContextFactory         = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory));
     Logger                 = logger ?? throw new ArgumentNullException(nameof(logger));
     ConsumeFunc            = options?.ConsumerFunc ?? (context => context.GetConsumer());
     ConsumePipe            = pipeBuilderFactory.Create(options?.Pipe ?? (builder => {}));
     ThrottledExecutionFunc = options?.ThrottleFuncFunc ?? (context => context.GetConsumeThrottleAction());
 }
コード例 #6
0
 public ExceptionHandlingMiddleware(IPipeBuilderFactory factory, ExceptionHandlingOptions options = null)
 {
     HandlingFunc = options?.HandlingFunc ?? ((exception, context, token) => Task.FromResult(0));
     InnerPipe    = factory.Create(options?.InnerPipe);
 }