Class MessageAggregatorFactory
- Namespace
- DotCompute.Core.Messaging
- Assembly
- DotCompute.Core.dll
Factory for creating message aggregators.
public sealed class MessageAggregatorFactory : IMessageAggregatorFactory
- Inheritance
-
MessageAggregatorFactory
- Implements
- Inherited Members
Constructors
MessageAggregatorFactory(ILoggerFactory, AggregationOptions?)
Creates a new message aggregator factory.
public MessageAggregatorFactory(ILoggerFactory loggerFactory, AggregationOptions? defaultOptions = null)
Parameters
loggerFactoryILoggerFactoryLogger factory for creating loggers.
defaultOptionsAggregationOptionsDefault aggregation options.
Methods
CreateAggregator<TResponse, TResult>(int, Func<IReadOnlyList<TResponse>, TResult>, TimeSpan, CancellationToken)
Creates a new aggregator that combines responses into a single result.
public IMessageAggregator<TResult> CreateAggregator<TResponse, TResult>(int expectedCount, Func<IReadOnlyList<TResponse>, TResult> aggregateFunc, TimeSpan timeout, CancellationToken cancellationToken = default) where TResponse : IResponseMessage
Parameters
expectedCountintNumber of expected responses.
aggregateFuncFunc<IReadOnlyList<TResponse>, TResult>Function to aggregate responses.
timeoutTimeSpanTimeout for aggregation.
cancellationTokenCancellationTokenCancellation token.
Returns
- IMessageAggregator<TResult>
A new message aggregator.
Type Parameters
TResponseThe response type.
TResultThe aggregated result type.
CreateFirstSuccess<TResponse>(int, TimeSpan, CancellationToken)
Creates a new aggregator that returns the first successful response.
public IMessageAggregator<TResponse?> CreateFirstSuccess<TResponse>(int expectedCount, TimeSpan timeout, CancellationToken cancellationToken = default) where TResponse : class, IResponseMessage
Parameters
expectedCountintNumber of expected responses.
timeoutTimeSpanTimeout for aggregation.
cancellationTokenCancellationTokenCancellation token.
Returns
- IMessageAggregator<TResponse>
A new message aggregator that returns the first success.
Type Parameters
TResponseThe response type.
CreateWaitAll<TResponse>(int, TimeSpan, CancellationToken)
Creates a new aggregator that waits for all responses.
public IMessageAggregator<IReadOnlyList<TResponse>> CreateWaitAll<TResponse>(int expectedCount, TimeSpan timeout, CancellationToken cancellationToken = default) where TResponse : IResponseMessage
Parameters
expectedCountintNumber of expected responses.
timeoutTimeSpanTimeout for aggregation.
cancellationTokenCancellationTokenCancellation token.
Returns
- IMessageAggregator<IReadOnlyList<TResponse>>
A new message aggregator that returns all responses.
Type Parameters
TResponseThe response type.