Beispiel #1
0
    Func <StreamSubscription, ResolvedEvent, CancellationToken, Task> EventAppeared(IProjection projection)
    {
        return(async(s, e, ct) =>
        {
            Console.WriteLine(
                $"Handling Projection {projection.GetType().Name} event {e.Event.EventType} id: {e.Event.EventId}");

            if (!projection.CanHandle(e.Event.EventType))
            {
                return;
            }

            var deserializedEvent = e.Deserialize();
            await projection.HandleAsync(e.Event.EventType, deserializedEvent, ct);

            await UpdatePositionAsync(projection.GetType(), e.OriginalPosition !.Value, ct);
        });
    }