Exemple #1
0
        private async Task Observe(
            ConsumeResult <Guid, IStreamEvent> result,
            IObserver observer,
            CancellationToken token)
        {
            var context = new EventContext(result);

            var metadata = context.GetMetadata();

            using (metadata.Count > 0 ? _logger.BeginScope(metadata) : null)
            {
                try
                {
                    await observer.OnEventAppeared(context, token);
                }
                catch (Exception ex)
                {
                    LogError(ex, "Event handling failed");

                    throw new EventHandlingException(context.Offset, "Event handling failed", ex);
                }
            }
        }