Skip to main content
Table of Contents

Interface ISagaMethodInvoker

Namespace
Stratara.Sagas.Abstractions
Assembly
Stratara.Sagas.dll

Reflection-cache facade that discovers HandleAsync methods on a saga and creates compiled delegates the dispatch can call. Implementations are expected to memoize lookups for process lifetime.

public interface ISagaMethodInvoker
Extension Methods

Methods

GetOrCreateDelegate(ISaga, Type)

Returns (or creates and caches) the compiled delegate that invokes HandleAsync on the saga for the given event type. Returns a no-op delegate if no matching method exists.

Func<ISaga, object, CancellationToken, Task> GetOrCreateDelegate(ISaga saga, Type eventType)

Parameters

saga ISaga

The saga to dispatch on.

eventType Type

The runtime event type to look up.

Returns

Func<ISaga, object, CancellationToken, Task>

GetOrCreateRelevantEventTypes(ISaga)

Returns the set of event types the saga declares a HandleAsync method for, caching the result.

Type[] GetOrCreateRelevantEventTypes(ISaga saga)

Parameters

saga ISaga

The saga to inspect.

Returns

Type[]

IsNoOp(Func<ISaga, object, CancellationToken, Task>)

Returns true if the given delegate is the cached no-op marker, i.e. the saga has no handler for the event type that produced it.

bool IsNoOp(Func<ISaga, object, CancellationToken, Task> delegateOperation)

Parameters

delegateOperation Func<ISaga, object, CancellationToken, Task>

A delegate returned by GetOrCreateDelegate(ISaga, Type).

Returns

bool