コード例 #1
0
        public PipelineDelegate.BatchMiddleware <T> Build()
        {
            Run <BatchHandlerPipelineEndpoint <T> >();

            PipelineDelegate.BatchMiddleware <T> batchApp = (messages, cancellationToken, context) => Task.CompletedTask;

            foreach (var middleware in _middleware.Reverse())
            {
                batchApp = middleware(batchApp);
            }

            return(batchApp);
        }
コード例 #2
0
 /// <summary>
 ///     Invokes the middleware
 /// </summary>
 /// <param name="messages">The messages to handle</param>
 /// <param name="cancellationToken">The current cancellation token</param>
 /// <param name="messageContext">The context of the message</param>
 /// <param name="next">The next middleware to run</param>
 protected abstract Task OnInvoke(IReadOnlyCollection <Message <T> > messages, CancellationToken cancellationToken, MessageContext messageContext, PipelineDelegate.BatchMiddleware <T> next);
コード例 #3
0
        /// <inheritdoc />
        public Task Invoke(IReadOnlyCollection <Message <T> > messages, CancellationToken cancellationToken, MessageContext messageContext, PipelineDelegate.BatchMiddleware <T> next)
        {
            if (messages is null)
            {
                Throw.ArgumentNullException(nameof(messages));
            }

            if (messageContext is null)
            {
                Throw.ArgumentNullException(nameof(messageContext));
            }

            cancellationToken.ThrowIfCancellationRequested();

            return(OnInvoke(messages, cancellationToken, messageContext, next));
        }