From 790a5b8abbb50bbcd5006924846aa709b797c72b Mon Sep 17 00:00:00 2001 From: Gabriele Santomaggio Date: Wed, 22 May 2024 14:16:27 +0200 Subject: [PATCH] remove the LastOffset() The method name may be misleading. It does not indicate the last offset of the stream. It indicates the last uncommited chunk id. This information is not necessary. The user should use CommittedChunkId(). Signed-off-by: Gabriele Santomaggio --- RabbitMQ.Stream.Client/StreamStats.cs | 8 +-- Tests/SystemTests.cs | 4 -- Tests/Tests.csproj | 84 +++++++++++++-------------- docs/asciidoc/query-stream.adoc | 2 - 4 files changed, 44 insertions(+), 54 deletions(-) diff --git a/RabbitMQ.Stream.Client/StreamStats.cs b/RabbitMQ.Stream.Client/StreamStats.cs index e96b5619..934c63be 100644 --- a/RabbitMQ.Stream.Client/StreamStats.cs +++ b/RabbitMQ.Stream.Client/StreamStats.cs @@ -2,6 +2,7 @@ // 2.0, and the Mozilla Public License, version 2.0. // Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. +using System; using System.Collections.Generic; namespace RabbitMQ.Stream.Client; @@ -29,12 +30,7 @@ public ulong FirstOffset() return (ulong)r; } - /// - /// The last offset in the stream. - /// - /// return last offset in the stream - /// throws NoOffsetException if there is no first offset yet - /// + [Obsolete("LastOffset() is deprecated, please use CommittedChunkId instead.")] public ulong LastOffset() { var r = _statistics.TryGetValue("last_chunk_id", out var value) ? value : -1; diff --git a/Tests/SystemTests.cs b/Tests/SystemTests.cs index 46138b49..b22e6419 100644 --- a/Tests/SystemTests.cs +++ b/Tests/SystemTests.cs @@ -126,9 +126,6 @@ public async void StreamStatus() Assert.Throws(() => { stats.FirstOffset(); } ); - Assert.Throws(() => { stats.LastOffset(); } - ); - Assert.Throws(() => { stats.CommittedChunkId(); } ); @@ -136,7 +133,6 @@ public async void StreamStatus() SystemUtils.Wait(); var statAfter = await system.StreamStats(stream); Assert.Equal((ulong)0, statAfter.FirstOffset()); - Assert.True(statAfter.LastOffset() > 0); Assert.True(statAfter.CommittedChunkId() > 0); await SystemUtils.CleanUpStreamSystem(system, stream); } diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index e97b21c0..5f563522 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -1,42 +1,42 @@ - - - - false - true - Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries. - Broadcom - Broadcom Inc. and/or its subsidiaries. - net6.0;net7.0;net8.0 - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - - - - + + + + false + true + Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries. + Broadcom + Broadcom Inc. and/or its subsidiaries. + net6.0;net7.0;net8.0 + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + + diff --git a/docs/asciidoc/query-stream.adoc b/docs/asciidoc/query-stream.adoc index e1efb943..ca4d09b5 100644 --- a/docs/asciidoc/query-stream.adoc +++ b/docs/asciidoc/query-stream.adoc @@ -29,8 +29,6 @@ The following methods are available: - `FirstOffset()`: first offset in the stream -- `LastOffset()`: last offset in the stream - - `CommittedChunkId()`: the ID (offset) of the committed chunk (block of messages) in the stream. It is the offset of the first message in the last chunk confirmed by a quorum of the stream cluster members (leader and replicas).