Skip to main content
Table of Contents

Interface IEventMapperFactory

Namespace
Stratara.Abstractions.EventSourcing
Assembly
Stratara.Abstractions.dll

Deserialises persisted EventStreamEntry rows or in-flight EventMessage envelopes into materialised IEvent instances.

public interface IEventMapperFactory
Extension Methods

Methods

MapToEventsAsync(IEnumerable<EventStreamEntry>, EventRelevance, CancellationToken)

Map the persisted stream entries a reader has a use for, leaving every other entry unread.

Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventStreamEntry> entries, EventRelevance relevance, CancellationToken cancellationToken = default)

Parameters

entries IEnumerable<EventStreamEntry>

The persisted stream entries.

relevance EventRelevance

Which events the reader has a use for.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>

The relevant events, in the entries' order.

Remarks

The default implementation maps every entry and keeps the relevant events, so an entry whose type is not registered still fails. The framework's mapper overrides it and resolves and decrypts only what relevance accepts. A decorator that forwards only the older overloads inherits the default and with it the older behaviour; a test double of this interface must set this overload up, or call its base.

MapToEventsAsync(IEnumerable<EventStreamEntry>, CancellationToken)

Map persisted stream entries to materialised events.

Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventStreamEntry> entries, CancellationToken cancellationToken = default)

Parameters

entries IEnumerable<EventStreamEntry>

The persisted stream entries to map.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>

MapToEventsAsync(IEnumerable<EventMessage>, EventRelevance, CancellationToken)

Map the wire-level event messages a reader has a use for, leaving every other message unread.

Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventMessage> messages, EventRelevance relevance, CancellationToken cancellationToken = default)

Parameters

messages IEnumerable<EventMessage>

The event messages.

relevance EventRelevance

Which events the reader has a use for.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>

The relevant events, in the messages' order.

Remarks

The default implementation maps every message and keeps the relevant events, so a message whose type is not registered still fails. The framework's mapper overrides it and resolves and decrypts only what relevance accepts. A decorator that forwards only the older overloads inherits the default and with it the older behaviour; a test double of this interface must set this overload up, or call its base.

MapToEventsAsync(IEnumerable<EventMessage>, CancellationToken)

Map wire-level event messages (e.g. from a bus) to materialised events.

Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventMessage> messages, CancellationToken cancellationToken = default)

Parameters

messages IEnumerable<EventMessage>

The event messages to map.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>