I'm evaluating an approach to domain service idempotency using HyperLogLog [HLL].
Aim of this approach would be to provide generic way of ensuring idempotency without storing large amounts of useless information. Only requirement being tolerance for occasional duplication (send 2 email instead of one).
In my scenario every service request is a message object with toHashCode function. The algorithm looks like this:
- Upon receiving request domain service calculates HLL[S1] cardinality and stores it as C1.
- Request hash[H] is added to the copy of HLL[S2] and the cardinality is stored as C2.
- If C1 == C2 then request is duplicated and S2 should be discarded.
- Otherwise request will be handled and hash[H] will be added to HLL[S1].
Did anybody encounter similar solution ? (like bloom filter)
What would be the downsides of this kind of solution ?