public async Task Append(EventMetadata m, IEvent e) { var streamName = GetStreamName(_projectionSchema.ProjectionHash); var data = _eventDataFactory.CreateLink(m, e, typeof(TProjection), _projectionSchema.ProjectionHash); Log.Debug("Appending to stream {streamName} {eventType}", streamName, e.GetType().Name); var result = await _connection.AppendToStreamAsync(streamName, AnyStreamRevision.Any, new [] { data }); }
public async Task <EventEnvelope[]> Append(Guid key, ulong version, Guid correlationId, IEnumerable <IEvent> published) { var streamName = GetStreamName(key); var publishedArray = published as IEvent[] ?? published.ToArray(); EventEnvelope[] data = new EventEnvelope[publishedArray.Length]; for (ulong i = 0; i < (ulong)publishedArray.Length; i++) { var ev = publishedArray[i]; data[i] = new EventEnvelope(ev, _metadataFactory.Create(key, correlationId, ev, version + i)); } var evData = data.Select(_eventDataFactory.Create); await _connection.AppendToStreamAsync(streamName, new StreamRevision(version), evData); _logger.Information("Writing event to stream {streamName} {eventNames}", streamName, publishedArray.Select(x => x.GetType().Name).ToArray()); return(data); }