示例#1
0
    public Task TruncateStream(
        StreamName stream,
        StreamTruncatePosition truncatePosition,
        ExpectedStreamVersion expectedVersion,
        CancellationToken cancellationToken
        )
    {
        var meta = new StreamMetadata(truncateBefore: truncatePosition.AsStreamPosition());

        return(TryExecute(
                   () => AnyOrNot(
                       expectedVersion,
                       () => _client.SetStreamMetadataAsync(
                           stream,
                           StreamState.Any,
                           meta,
                           cancellationToken: cancellationToken
                           ),
                       () => _client.SetStreamMetadataAsync(
                           stream,
                           expectedVersion.AsStreamRevision(),
                           meta,
                           cancellationToken: cancellationToken
                           )
                       ),
                   stream,
                   () => new ErrorInfo(
                       "Unable to truncate stream {Stream} at {Position}",
                       stream,
                       truncatePosition
                       ),
                   (s, ex) => new TruncateStreamException(s, ex)
                   ));
    }
 public static StreamPosition AsStreamPosition(this StreamTruncatePosition position)
 => StreamPosition.FromInt64(position.Value);
示例#3
0
 public Task TruncateStream(
     StreamName stream,
     StreamTruncatePosition truncatePosition,
     ExpectedStreamVersion expectedVersion,
     CancellationToken cancellationToken
     ) => default !;