public async Task AppendEventsAsync(IReadOnlyCollection <JournaledEvent> events) { Require.NotNull(events, "events"); ConnectionState.EnsureConnectionIsActive(); if (events.Count == 0) { return; } var fromVersion = m_endOfStream.Version; var mutatedEvents = new List <JournaledEvent>(events.Count); mutatedEvents.AddRange(events.Select(journaledEvent => m_mutationPipeline.Mutate(journaledEvent))); await m_pendingNotification.AddAsync(StreamName, fromVersion, mutatedEvents.Count); m_endOfStream = await m_journal.AppendEventsAsync(StreamName, m_endOfStream, mutatedEvents); await m_notificationHub.NotifyAsync(new EventStreamUpdated(StreamName, fromVersion, m_endOfStream.Version)); await m_pendingNotification.DeleteAsync(StreamName, fromVersion); }
private async Task ProcessStreamNotificationAsync(string streamName, List <EventStreamUpdated> notifications) { await m_notificationHub.NotifyAsync(notifications.First()); await m_pendingNotifications.DeleteAsync(streamName, notifications.SelectToArray(n => n.FromVersion)); }