Observe increments / increments with ReplicateTo control
I want to be able to rely on a sequential counter never returning a previous id. This is the normal behaviour when calling incr().
However, if you call incr() and then the master node for that counter fails before the value has been replicated, after a failover of that node your next successful call to incr() will return a previously issued id.
If my understanding of this is correct, then it would be nice to be able to have an incr() call with a ReplicateTo parameter, or the ability to observe the value was written.
I can't see how to do this in the Java API at the present time. Is there a way I can do this with the current API?
I'm not sure I can easily refactor. I'm using the sequence ID to implement idempotency on a work queue. If an item has been processed and deleted, the add() would incorrectly succeed without error on the duplicate ID.
I suppose I could set a timeout on the items instead of deleting them, where the timeout is long enough to ride through any failover hiccups, but that seems a bit hand wavy.
First off, you may want to consider whether or not you can refactor this a bit. For example, if the sequence is used as part of other item creations, can you use an add()? It would be best if you could turn that around into an optimistic approach.
Though the Java client doesn't have durability requirement arguments for incr(), you can probably do this, albeit somewhat manually, with the lower level observe() method right now. You'll need to get into the Operation's details for the CAS I believe.