Table of Contents

Class EventVersionManager

Namespace
Excalibur.EventSourcing.Upcasting
Assembly
Excalibur.EventSourcing.dll

Manages event version upgrades by maintaining a registry of upgraders and finding optimal upgrade paths between versions.

public class EventVersionManager
Inheritance
EventVersionManager
Inherited Members

Remarks

The EventVersionManager uses a breadth-first search algorithm to find the shortest upgrade path when multiple intermediate versions exist. This ensures events are upgraded efficiently through the minimal number of transformations.

Constructors

EventVersionManager(ILogger<EventVersionManager>)

Initializes a new instance of the EventVersionManager class.

public EventVersionManager(ILogger<EventVersionManager> logger)

Parameters

logger ILogger<EventVersionManager>

The logger.

Exceptions

ArgumentNullException

Thrown when logger is null.

Methods

GetRegisteredEventTypes()

Gets all registered event types.

public IEnumerable<string> GetRegisteredEventTypes()

Returns

IEnumerable<string>

A collection of registered event types.

GetUpgradersForEventType(string)

Gets all upgraders for a specific event type.

public IEnumerable<IEventUpgrader> GetUpgradersForEventType(string eventType)

Parameters

eventType string

The event type.

Returns

IEnumerable<IEventUpgrader>

A collection of upgraders for the event type.

RegisterUpgrader(IEventUpgrader)

Registers an event upgrader.

public void RegisterUpgrader(IEventUpgrader upgrader)

Parameters

upgrader IEventUpgrader

The upgrader to register.

Remarks

Type and version metadata is captured once at registration. Later changes to consumer getters do not remap an existing registration. The original upgrader performs the transformation.

Exceptions

ArgumentNullException

Thrown when upgrader is null.

InvalidOperationException

Thrown when an upgrader for the same event type and version range already exists.

UpgradeEvent(string, object, int, int)

Upgrades an event to the specified version.

public object UpgradeEvent(string eventType, object eventData, int fromVersion, int toVersion)

Parameters

eventType string

The event type.

eventData object

The event data.

fromVersion int

The current version of the event.

toVersion int

The target version.

Returns

object

The upgraded event.

Exceptions

ArgumentException

Thrown when the event type is null or empty.

ArgumentNullException

Thrown when eventData is null.

InvalidOperationException

Thrown when no upgraders are registered for the event type or when no upgrade path is found.