EventStore / EventStoreDB-Client-Java

Official Asynchronous Java 8+ Client Library for EventStoreDB 20.6+
https://eventstore.com
Apache License 2.0
63 stars 20 forks source link

Next expected version no longer available in version 4+ #228

Closed danieljelder closed 1 year ago

danieljelder commented 1 year ago

Hi,

We are currently at client version 3.0.2.

When performing an appendToStream, we get a write result back which contains a nextExpectedVersion, which is a long. The caller then receives this version, and we regularly use it to poll the read model to check when it’s available.

I have been experimenting a bit with client version 4.1.1 to see what changes need to be made. I noticed there isn’t a nextExpectedVersion anymore.

Instead there’s a nextExpectedRevision, but this is an abstract class of ExpectedRevision. One of the subclasses is a SpecificExpectedRevision, but that isn’t public, and so we can’t extract the version from that.

Would it be possible to expose the revision number?

jezovuk commented 1 year ago

We've worked around this limitation via reflection, but it would indeed be nice to get the ability to access the value directly.

YoEight commented 1 year ago

@danieljelder @jezovuk Could you share what you do with a raw integer value? Because the library never used raw integers for expected version.

danieljelder commented 1 year ago

@YoEight apologies, I got two versions of our code confused.

In our latest code using v3.0.2, we use WriteResult.getNextExpectedRevision().getValueUnsigned().

YoEight commented 1 year ago

@danieljelder what do you do with that unsigned integer?

danieljelder commented 1 year ago

The caller uses the version to check if the read model has updated before performing other operations that may rely on it.

YoEight commented 1 year ago

If that's something you don't persist, the new type does implement equals properly. I could also add a compare function too. If it's not enough, I could also add a method that returns a raw integer representation.

danieljelder commented 1 year ago

The raw integer representation would be great, as the value is passed between services so we can't use comparisons on the class.