private EventStreamCursor(EventStreamHeader streamHeader, StreamVersion fromVersion, FetchEvents fetch) { Require.NotNull(fetch, "fetch"); m_state = new InitialCursorState(streamHeader, fromVersion, fetch); m_slice = EventStreamSlice.Empty; m_cursorStreamVersion = fromVersion; }
public EventStreamCursor(EventStreamPosition position, StreamVersion fromVersion, FetchEvents fetch) { Require.NotNull(fetch, "fetch"); if (EventStreamPosition.IsNewStream(position)) { m_state = new EndOfStreamCursorState(); m_slice = EventStreamSlice.Empty; } else { m_state = new InitialCursorState(position, fromVersion, fetch); } }
public override async Task<EventStreamSlice> FetchSlice() { var slice = new EventStreamSlice(m_position, await m_fetch(m_currentSlicePosition.Version.Increment(1))); if (slice.EndOfStream) { NextState = new EndOfStreamCursorState(); } else { NextState = new FetchingCursorState(m_position, slice.SlicePosition, m_fetch); } return slice; }
public override async Task <EventStreamSlice> FetchSlice() { var fetchResult = await m_fetch(m_version); var slice = new EventStreamSlice(fetchResult.Events); if (fetchResult.IsFetchingCompleted) { NextState = new EndOfStreamCursorState(StreamHeader); } else { NextState = new FetchingCursorState(StreamHeader, slice.ToStreamVersion.Increment(), m_fetch); } return(slice); }
public async Task FetchSlice() { m_slice = await m_state.FetchSlice(); m_state = m_state.NextState; }
private EventStreamCursor() { m_state = new EndOfStreamCursorState(EventStreamHeader.Unknown); m_slice = EventStreamSlice.Empty; }
private EventStreamCursor(EventStreamHeader streamHeader, StreamVersion fromVersion) { m_state = new EndOfStreamCursorState(streamHeader); m_slice = EventStreamSlice.Empty; m_cursorStreamVersion = fromVersion; }