Skip to content

Commit 6ded862

Browse files
authored
remove the LastOffset() (#380)
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 <[email protected]>
1 parent 5250316 commit 6ded862

File tree

4 files changed

+44
-54
lines changed

4 files changed

+44
-54
lines changed

RabbitMQ.Stream.Client/StreamStats.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// 2.0, and the Mozilla Public License, version 2.0.
33
// Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
44

5+
using System;
56
using System.Collections.Generic;
67

78
namespace RabbitMQ.Stream.Client;
@@ -29,12 +30,7 @@ public ulong FirstOffset()
2930
return (ulong)r;
3031
}
3132

32-
/// <summary>
33-
/// The last offset in the stream.
34-
///
35-
/// return last offset in the stream
36-
/// throws NoOffsetException if there is no first offset yet
37-
/// </summary>
33+
[Obsolete("LastOffset() is deprecated, please use CommittedChunkId instead.")]
3834
public ulong LastOffset()
3935
{
4036
var r = _statistics.TryGetValue("last_chunk_id", out var value) ? value : -1;

Tests/SystemTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,13 @@ public async void StreamStatus()
126126
Assert.Throws<OffsetNotFoundException>(() => { stats.FirstOffset(); }
127127
);
128128

129-
Assert.Throws<OffsetNotFoundException>(() => { stats.LastOffset(); }
130-
);
131-
132129
Assert.Throws<OffsetNotFoundException>(() => { stats.CommittedChunkId(); }
133130
);
134131

135132
await SystemUtils.PublishMessages(system, stream, 500, _testOutputHelper);
136133
SystemUtils.Wait();
137134
var statAfter = await system.StreamStats(stream);
138135
Assert.Equal((ulong)0, statAfter.FirstOffset());
139-
Assert.True(statAfter.LastOffset() > 0);
140136
Assert.True(statAfter.CommittedChunkId() > 0);
141137
await SystemUtils.CleanUpStreamSystem(system, stream);
142138
}

Tests/Tests.csproj

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<IsPackable>false</IsPackable>
5-
<MinVerSkip>true</MinVerSkip>
6-
<Copyright>Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries.</Copyright>
7-
<Authors>Broadcom</Authors>
8-
<Company>Broadcom Inc. and/or its subsidiaries.</Company>
9-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
10-
</PropertyGroup>
11-
12-
<ItemGroup>
13-
<PackageReference Include="AltCover" />
14-
<PackageReference Include="AmqpNetLite" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
16-
<PackageReference Include="RabbitMQ.Client" />
17-
<PackageReference Include="System.IO.Hashing" />
18-
<PackageReference Include="xunit" />
19-
<PackageReference Include="xunit.runner.visualstudio">
20-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21-
<PrivateAssets>all</PrivateAssets>
22-
</PackageReference>
23-
<PackageReference Include="Xunit.SkippableFact" />
24-
<PackageReference Include="coverlet.collector">
25-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26-
<PrivateAssets>all</PrivateAssets>
27-
</PackageReference>
28-
</ItemGroup>
29-
30-
<ItemGroup>
31-
<ProjectReference Include="..\RabbitMQ.Stream.Client\RabbitMQ.Stream.Client.csproj" />
32-
</ItemGroup>
33-
34-
<ItemGroup>
35-
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
36-
</ItemGroup>
37-
38-
<ItemGroup>
39-
<None Include="Resources\**" CopyToOutputDirectory="PreserveNewest" LinkBase="TestFiles\" />
40-
</ItemGroup>
41-
42-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<IsPackable>false</IsPackable>
5+
<MinVerSkip>true</MinVerSkip>
6+
<Copyright>Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries.</Copyright>
7+
<Authors>Broadcom</Authors>
8+
<Company>Broadcom Inc. and/or its subsidiaries.</Company>
9+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="AltCover" />
14+
<PackageReference Include="AmqpNetLite" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
16+
<PackageReference Include="RabbitMQ.Client" />
17+
<PackageReference Include="System.IO.Hashing" />
18+
<PackageReference Include="xunit" />
19+
<PackageReference Include="xunit.runner.visualstudio">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="Xunit.SkippableFact" />
24+
<PackageReference Include="coverlet.collector">
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
<PrivateAssets>all</PrivateAssets>
27+
</PackageReference>
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\RabbitMQ.Stream.Client\RabbitMQ.Stream.Client.csproj" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<None Include="Resources\**" CopyToOutputDirectory="PreserveNewest" LinkBase="TestFiles\" />
40+
</ItemGroup>
41+
42+
</Project>

docs/asciidoc/query-stream.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ The following methods are available:
2929

3030
- `FirstOffset()`: first offset in the stream
3131
32-
- `LastOffset()`: last offset in the stream
33-
3432
- `CommittedChunkId()`: the ID (offset) of the committed chunk (block of messages) in the stream.
3533
3634
It is the offset of the first message in the last chunk confirmed by a quorum of the stream cluster members (leader and replicas).

0 commit comments

Comments
 (0)