nmcb / dads

Reading and counter storage
The Unlicense
0 stars 0 forks source link

Implement cassandra optimistic locking with retry [workaround] #10

Open nmcb opened 3 years ago

nmcb commented 3 years ago

The currently implemented lcd asynchronous boundary is at repository level. Since we allow multiple sourceIds per proto api storage request we allow multiple overlapping updates thus allowing for non-deterministic updates in the cassandra realtime and counter repositories. This is in absence of an inbound update batch event store, i.e. a cross systeem boundary CQRS architecture. At a minimum the implementation requires optimistic locking with retry to guarantee data correctness at the inbound proto interface.

implement optimistic locking i.e.:

https://github.com/nmcb/dads/blob/master/src/main/scala/dads/v1/CounterRepository.scala#L61 https://github.com/nmcb/dads/blob/master/src/main/scala/dads/v1/RealTimeDecimalRepository.scala#L85

ref:

https://www.oreilly.com/library/view/learning-apache-cassandra/9781787127296/5e5991cb-eb1e-4459-9114-1d86e974e927.xhtml

https://youtu.be/-avpiJS8Nls