/// <inheritdoc /> public async Task <IReadOnlyList <TItem> > ReadManyAsync(long startSequence, int minCount, int maxCount) { if (startSequence < 0) { throw new ArgumentOutOfRangeException(nameof(startSequence)); } if (minCount < 0) { throw new ArgumentOutOfRangeException(nameof(minCount), "The value of minCount must be equal to, or greater than, zero."); } if (maxCount < minCount) { throw new ArgumentOutOfRangeException(nameof(maxCount), "The value of maxCount must be greater than, or equal to, the value of minCount."); } var capacity = await GetCapacityAsync().CfAwait(); if (minCount > capacity) { throw new ArgumentOutOfRangeException(nameof(minCount), "The value of minCount must be smaller than, or equal to, the capacity."); } if (maxCount > MaxBatchSize) { throw new ArgumentOutOfRangeException(nameof(maxCount), "The value of maxCount must be lower than, or equal to, the max batch size."); } var requestMessage = RingbufferReadManyCodec.EncodeRequest(Name, startSequence, minCount, maxCount, null); var responseMessage = await Cluster.Messaging.SendToPartitionOwnerAsync(requestMessage, PartitionId).CfAwait(); var response = RingbufferReadManyCodec.DecodeResponse(responseMessage).Items; return(new ReadOnlyLazyList <TItem>(response, SerializationService)); }
public Task <IList <T> > ReadManyAsync(long startSequence, int minCount, int maxCount) { CheckSequence(startSequence); ValidationUtil.ThrowExceptionIfTrue(minCount < 0, "minCount can't be smaller than 0"); ValidationUtil.ThrowExceptionIfTrue(maxCount < minCount, "maxCount should be equal or larger than minCount"); ValidationUtil.ThrowExceptionIfTrue(minCount > Capacity(), "the minCount should be smaller than or equal to the capacity"); ValidationUtil.ThrowExceptionIfTrue(maxCount > MaxBatchSize, "maxCount can't be larger than " + MaxBatchSize); var request = RingbufferReadManyCodec.EncodeRequest(GetName(), startSequence, minCount, maxCount, null); return(InvokeAsync(request, GetPartitionKey(), m => ToList <T>(RingbufferReadManyCodec.DecodeResponse(m).items))); }