epoplavskis / photon-pump

A TCP eventstore client for modern Python
MIT License
48 stars 9 forks source link

explicitly handle expected version failures (and tidy up WriteEvents.reply()) #230

Open hjwp opened 4 years ago

hjwp commented 4 years ago

eventstore supports setting expected_version on an event, to allow for optimistic concurrency

https://eventstore.com/docs/http-api/creating-writing-a-stream/index.html?tabs=tabid-1%2Ctabid-3%2Ctabid-5%2Ctabid-7%2Ctabid-17%2Ctabid-11%2Ctabid-13%2Ctabid-15#expected-version-header

we support setting that flag, but we don't currently (i think) handle the errors that would come back.

implementation would be in the async def reply() of class WriteEvents. currently the only special case is for AccessDenied. we should add a check for whatever the expected-version-error is.

at that point the reply() method will be quite long. consider switching to the same pattern we use for Read conversations, which is delegating to a wrapper called eg WriteEventCompleted which defines a .dispatch() method. See for example ReadEvent.reply() and class ReadEventCompleted