/// <summary> /// Reads the events from a stream in a specified partition. /// </summary> /// <param name="partition">The partition.</param> /// <param name="startVersion">The start version.</param> /// <param name="sliceSize">Size of the slice.</param> /// <returns> /// The slice of the stream, which contains events that has been read /// </returns> /// <exception cref="ArgumentNullException"> /// If <paramref name="partition"/> is <c>null</c> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="startVersion"/> < 1 /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="sliceSize"/> < 1 /// </exception> /// <exception cref="StreamNotFoundException"> /// If there is no stream in a given partition /// </exception> public static StreamSlice <EventProperties> Read( Partition partition, int startVersion = 1, int sliceSize = DefaultSliceSize) { Requires.NotNull(partition, "partition"); Requires.GreaterThanOrEqualToOne(startVersion, "startVersion"); Requires.GreaterThanOrEqualToOne(sliceSize, "sliceSize"); return(new ReadOperation <EventProperties>(partition, startVersion, sliceSize) .Execute(BuildEventProperties)); }
/// <summary> /// Initiates an asynchronous operation that reads the events from a stream in a specified partition. /// </summary> /// <param name="partition">The partition.</param> /// <param name="startVersion">The start version.</param> /// <param name="sliceSize">Size of the slice.</param> /// <returns> /// The promise, that wil eventually return the slice of the stream, /// which contains events that has been read; or will fail with exception /// </returns> /// <exception cref="ArgumentNullException"> /// If <paramref name="partition"/> is <c>null</c> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="startVersion"/> < 1 /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="sliceSize"/> < 1 /// </exception> /// <exception cref="StreamNotFoundException"> /// If there is no stream in a given partition /// </exception> public static Task <StreamSlice <EventProperties> > ReadAsync( Partition partition, int startVersion = 1, int sliceSize = DefaultSliceSize) { Requires.NotNull(partition, nameof(partition)); Requires.GreaterThanOrEqualToOne(startVersion, nameof(startVersion)); Requires.GreaterThanOrEqualToOne(sliceSize, nameof(sliceSize)); return(new ReadOperation <EventProperties>(partition, startVersion, sliceSize) .ExecuteAsync(BuildEventProperties)); }
/// <summary> /// Initiates an asynchronous operation that reads the events from a stream in a specified partition. /// </summary> /// <typeparam name="T">The type of event entity to return</typeparam> /// <param name="partition">The partition.</param> /// <param name="startVersion">The start version.</param> /// <param name="sliceSize">Size of the slice.</param> /// <returns> /// The promise, that wil eventually return the slice of the stream, /// which contains events that has been read; or will fail with exception /// </returns> /// <exception cref="ArgumentNullException"> /// If <paramref name="partition"/> is <c>null</c> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="startVersion"/> < 1 /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="sliceSize"/> < 1 /// </exception> /// <exception cref="StreamNotFoundException"> /// If there is no stream in a given partition /// </exception> public static Task <StreamSlice <T> > ReadAsync <T>( Partition partition, int startVersion = 1, int sliceSize = DefaultSliceSize) where T : class, new() { Requires.NotNull(partition, "partition"); Requires.GreaterThanOrEqualToOne(startVersion, "startVersion"); Requires.GreaterThanOrEqualToOne(sliceSize, "sliceSize"); return(new ReadOperation <T>(partition, startVersion, sliceSize).ExecuteAsync()); }