internal StreamAction Append(DocumentSessionBase session, string stream, params object[] events) { EnsureAsStringStorage(session); if (session.UnitOfWork.TryFindStream(stream, out var eventStream)) { eventStream.AddEvents(events); } else { eventStream = StreamAction.Append(stream, events); session.UnitOfWork.Streams.Add(eventStream); } return(eventStream); }
internal StreamAction StartStream(DocumentSessionBase session, Guid id, params object[] events) { EnsureAsGuidStorage(session); if (id == Guid.Empty) { throw new ArgumentOutOfRangeException(nameof(id), "Cannot use an empty Guid as the stream id"); } var stream = StreamAction.Start(this, id, events); session.WorkTracker.Streams.Add(stream); return(stream); }
internal StreamAction StartStream(DocumentSessionBase session, string streamKey, params object[] events) { EnsureAsStringStorage(session); if (streamKey.IsEmpty()) { throw new ArgumentOutOfRangeException(nameof(streamKey), "The stream key cannot be null or empty"); } var stream = StreamAction.Start(this, streamKey, events); session.WorkTracker.Streams.Add(stream); return(stream); }
internal StreamAction StartEmptyStream(DocumentSessionBase session, string key, params object[] events) { EnsureAsStringStorage(session); if (key.IsEmpty()) { throw new ArgumentOutOfRangeException(nameof(key), "Cannot use an empty or null string as the stream key"); } var stream = new StreamAction(key, StreamActionType.Start); session.WorkTracker.Streams.Add(stream); return(stream); }
internal StreamAction Append(DocumentSessionBase session, string stream, params object[] events) { EnsureAsStringStorage(session); var wrapped = events.Select(BuildEvent).ToArray(); if (session.WorkTracker.TryFindStream(stream, out var eventStream)) { eventStream.AddEvents(wrapped); } else { eventStream = StreamAction.Append(stream, wrapped); session.WorkTracker.Streams.Add(eventStream); } return(eventStream); }
internal bool TryCreateTombstoneBatch(DocumentSessionBase session, out UpdateBatch batch) { if (session.UnitOfWork.Streams.Any()) { var stream = StreamAction.ForTombstone(); var tombstone = new Tombstone(); var mapping = EventMappingFor <Tombstone>(); var operations = new List <IStorageOperation>(); var storage = session.EventStorage(); var dotNetTypeName = DotnetTypeNameFor(typeof(Tombstone)); operations.Add(_establishTombstone.Value); var tombstones = session.UnitOfWork.Streams .SelectMany(x => x.Events) .Select(x => new Event <Tombstone>(tombstone) { Sequence = x.Sequence, Version = x.Version, TenantId = x.TenantId, StreamId = EstablishTombstoneStream.StreamId, StreamKey = EstablishTombstoneStream.StreamKey, Id = CombGuidIdGeneration.NewGuid(), EventTypeName = mapping.EventTypeName, DotNetTypeName = dotNetTypeName }) .Select(e => storage.AppendEvent(this, session, stream, e)); operations.AddRange(tombstones); batch = new UpdateBatch(operations); return(true); } batch = null; return(false); }
internal StreamAction Append(DocumentSessionBase session, Guid stream, params object[] events) { EnsureAsGuidStorage(session); if (stream == Guid.Empty) { throw new ArgumentOutOfRangeException(nameof(stream), "Cannot use an empty Guid as the stream id"); } var wrapped = events.Select(BuildEvent).ToArray(); if (session.WorkTracker.TryFindStream(stream, out var eventStream)) { eventStream.AddEvents(wrapped); } else { eventStream = StreamAction.Append(stream, wrapped); session.WorkTracker.Streams.Add(eventStream); } return(eventStream); }
internal StreamAction Append(DocumentSessionBase session, string stream, params object[] events) { EnsureAsStringStorage(session); if (stream.IsEmpty()) { throw new ArgumentOutOfRangeException(nameof(stream), "The stream key cannot be null or empty"); } var wrapped = events.Select(BuildEvent).ToArray(); if (session.WorkTracker.TryFindStream(stream, out var eventStream)) { eventStream.AddEvents(wrapped); } else { eventStream = StreamAction.Append(stream, wrapped); session.WorkTracker.Streams.Add(eventStream); } return(eventStream); }
public abstract IStorageOperation UpdateStreamVersion(StreamAction stream);
public abstract IQueryHandler <StreamState> QueryForStream(StreamAction stream);
public abstract IStorageOperation InsertStream(StreamAction stream);
public abstract IStorageOperation AppendEvent(EventGraph events, IMartenSession session, StreamAction stream, IEvent e);
public Task <StreamState> FetchStreamStateAsync(Guid streamId, CancellationToken token = default) { var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamId, _tenant.TenantId)); return(_session.ExecuteHandlerAsync(handler, token)); }
public StreamState FetchStreamState(Guid streamId) { var handler = eventStorage().QueryForStream(StreamAction.ForReference(streamId, _tenant.TenantId)); return(_session.ExecuteHandler(handler)); }
public override Marten.Internal.Operations.IStorageOperation AppendEvent(Marten.Events.EventGraph events, Marten.Internal.IMartenSession session, Marten.Events.StreamAction stream, Marten.Events.IEvent e) { return(new Marten.Generated.EventStore.AppendEventOperation(stream, e)); }
public override Marten.Internal.Operations.IStorageOperation InsertStream(Marten.Events.StreamAction stream) { return(new Marten.Generated.EventStore.GeneratedInsertStream(stream)); }
public GeneratedInsertStream(Marten.Events.StreamAction stream) : base(stream) { _stream = stream; }
public StreamState FetchStreamState(string streamKey) { var handler = _tenant.EventStorage().QueryForStream(StreamAction.ForReference(streamKey, _tenant)); return(_session.ExecuteHandler(handler)); }
public GeneratedStreamVersionOperation(Marten.Events.StreamAction stream) : base(stream) { _stream = stream; }
public override Marten.Linq.QueryHandlers.IQueryHandler <Marten.Events.StreamState> QueryForStream(Marten.Events.StreamAction stream) { return(new Marten.Generated.EventStore.GeneratedStreamStateQueryHandler(stream.Id)); }
public override Marten.Internal.Operations.IStorageOperation UpdateStreamVersion(Marten.Events.StreamAction stream) { return(new Marten.Generated.EventStore.GeneratedStreamVersionOperation(stream)); }
public Task <StreamState> FetchStreamStateAsync(string streamKey, CancellationToken token = new CancellationToken()) { var handler = _tenant.EventStorage().QueryForStream(StreamAction.ForReference(streamKey, _tenant)); return(_session.ExecuteHandlerAsync(handler, token)); }
public AppendEventOperation(Marten.Events.StreamAction stream, Marten.Events.IEvent e) : base(stream, e) { _stream = stream; _e = e; }