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()); }
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); }
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); }
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); }
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()); }
public ExceptionHandlingMiddleware(IPipeBuilderFactory factory, ExceptionHandlingOptions options = null) { HandlingFunc = options?.HandlingFunc ?? ((exception, context, token) => Task.FromResult(0)); InnerPipe = factory.Create(options?.InnerPipe); }