public MultiStreamEventReader(IPublisher publisher, Guid eventReaderCorrelationId, IPrincipal readAs, int phase, string[] streams, Dictionary <string, int> fromPositions, bool resolveLinkTos, ITimeProvider timeProvider, bool stopOnEof = false, int?stopAfterNEvents = null) : base(publisher, eventReaderCorrelationId, readAs, stopOnEof, stopAfterNEvents) { if (streams == null) { throw new ArgumentNullException("streams"); } if (timeProvider == null) { throw new ArgumentNullException("timeProvider"); } if (streams.Length == 0) { throw new ArgumentException("streams"); } _streams = new HashSet <string>(streams); _eofs = _streams.ToDictionary(v => v, v => false); var positions = CheckpointTag.FromStreamPositions(phase, fromPositions); ValidateTag(positions); _fromPositions = positions; _resolveLinkTos = resolveLinkTos; _timeProvider = timeProvider; foreach (var stream in streams) { _preparePositions.Add(stream, null); } }
public override CheckpointTag AdjustTag(CheckpointTag tag) { if (tag.Mode_ == CheckpointTag.Mode.MultiStream) { int p; return(CheckpointTag.FromStreamPositions( _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); } switch (tag.Mode_) { case CheckpointTag.Mode.EventTypeIndex: throw new NotSupportedException("Conversion from EventTypeIndex to MultiStream position tag is not supported"); case CheckpointTag.Mode.Stream: int p; return (CheckpointTag.FromStreamPositions( _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); case CheckpointTag.Mode.PreparePosition: throw new NotSupportedException("Conversion from PreparePosition to MultiStream position tag is not supported"); case CheckpointTag.Mode.Position: throw new NotSupportedException("Conversion from Position to MultiStream position tag is not supported"); default: throw new Exception(); } }
public override CheckpointTag AdjustTag(CheckpointTag tag) { if (tag.Phase < Phase) { return(tag); } if (tag.Phase > Phase) { throw new ArgumentException( string.Format("Invalid checkpoint tag phase. Expected less or equal to: {0} Was: {1}", Phase, tag.Phase), "tag"); } if (tag.Mode_ == CheckpointTag.Mode.MultiStream) { long p; return(CheckpointTag.FromStreamPositions( tag.Phase, _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); } switch (tag.Mode_) { case CheckpointTag.Mode.EventTypeIndex: throw new NotSupportedException( "Conversion from EventTypeIndex to MultiStream position tag is not supported"); case CheckpointTag.Mode.Stream: long p; return(CheckpointTag.FromStreamPositions( tag.Phase, _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); case CheckpointTag.Mode.PreparePosition: throw new NotSupportedException( "Conversion from PreparePosition to MultiStream position tag is not supported"); case CheckpointTag.Mode.Position: throw new NotSupportedException( "Conversion from Position to MultiStream position tag is not supported"); default: throw new NotSupportedException(string.Format( "The given checkpoint is invalid. Possible causes might include having written an event to the projection's managed stream. The bad checkpoint: {0}", tag.ToString())); } }
public override CheckpointTag AdjustTag(CheckpointTag tag) { if (tag.Phase < Phase) { return(tag); } if (tag.Phase > Phase) { throw new ArgumentException( string.Format("Invalid checkpoint tag phase. Expected less or equal to: {0} Was: {1}", Phase, tag.Phase), "tag"); } if (tag.Mode_ == CheckpointTag.Mode.MultiStream) { int p; return(CheckpointTag.FromStreamPositions( tag.Phase, _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); } switch (tag.Mode_) { case CheckpointTag.Mode.EventTypeIndex: throw new NotSupportedException( "Conversion from EventTypeIndex to MultiStream position tag is not supported"); case CheckpointTag.Mode.Stream: int p; return(CheckpointTag.FromStreamPositions( tag.Phase, _streams.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1))); case CheckpointTag.Mode.PreparePosition: throw new NotSupportedException( "Conversion from PreparePosition to MultiStream position tag is not supported"); case CheckpointTag.Mode.Position: throw new NotSupportedException( "Conversion from Position to MultiStream position tag is not supported"); default: throw new Exception(); } }
public MultiStreamReaderEventDistributionPoint( IPublisher publisher, Guid distibutionPointCorrelationId, string[] streams, Dictionary <string, int> fromPositions, bool resolveLinkTos) : base(publisher, distibutionPointCorrelationId) { if (streams == null) { throw new ArgumentNullException("streams"); } if (streams.Length == 0) { throw new ArgumentException("streams"); } _streams = new HashSet <string>(streams); var positions = CheckpointTag.FromStreamPositions(fromPositions); ValidateTag(positions); _fromPositions = positions; _resolveLinkTos = resolveLinkTos; foreach (var stream in streams) { _preparePositions.Add(stream, null); } }
public override CheckpointTag MakeZeroCheckpointTag() { return(CheckpointTag.FromStreamPositions(Phase, _streams.ToDictionary(v => v, v => ExpectedVersion.NoStream))); }