Table of Contents

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

loggerFactory ILoggerFactory

Logger factory for creating loggers.

defaultOptions AggregationOptions

Default 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

expectedCount int

Number of expected responses.

aggregateFunc Func<IReadOnlyList<TResponse>, TResult>

Function to aggregate responses.

timeout TimeSpan

Timeout for aggregation.

cancellationToken CancellationToken

Cancellation token.

Returns

IMessageAggregator<TResult>

A new message aggregator.

Type Parameters

TResponse

The response type.

TResult

The 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

expectedCount int

Number of expected responses.

timeout TimeSpan

Timeout for aggregation.

cancellationToken CancellationToken

Cancellation token.

Returns

IMessageAggregator<TResponse>

A new message aggregator that returns the first success.

Type Parameters

TResponse

The 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

expectedCount int

Number of expected responses.

timeout TimeSpan

Timeout for aggregation.

cancellationToken CancellationToken

Cancellation token.

Returns

IMessageAggregator<IReadOnlyList<TResponse>>

A new message aggregator that returns all responses.

Type Parameters

TResponse

The response type.