rabbitmq / rabbitmq-stream-dotnet-client

RabbitMQ client for the stream protocol
https://rabbitmq.github.io/rabbitmq-stream-dotnet-client/stable/htmlsingle/index.html
Other
122 stars 41 forks source link

Avoid throwing OffsetNotFoundException in StreamSystem.QueryOffset(string, string) #370

Open bangjiehan opened 8 months ago

bangjiehan commented 8 months ago

Is your feature request related to a problem? Please describe.

I think only when there indeed is something wrong does C# throw a exception. Or at least there is some way to check before, for example call File.Exists before calling File.Read~. There seems no way to check whether Offset exist or not before calling QueryOffset.

Describe the solution you'd like

Add one of the following overloads or modify current implementation of QueryOffset.

bool exist = StreamSystem.TryQueryOffset(string, string, out ulong offset)
ulong? offset = StreamSystem.TryQueryOffset(string, string)

Describe alternatives you've considered

No response

Additional context

No response

Gsantomaggio commented 8 months ago

Thank you @bangjiehan I think you are right.

We can add bool exist = StreamSystem.TryQueryOffset(string, string, out ulong offset) (it is more idiomatic)

The important thing is to keep the current implementation. We could mark it as deprecated and remove it on 2.0