logoalt Hacker News

shiandowtoday at 9:50 AM4 repliesview on HN

This seems to assume retrying a command should result in the same response, but I am not sure I agree.

Idempotency is about state, not communication. Send the same payment twice and one of them should respond "payment already exists".


Replies

Joltertoday at 10:37 AM

I don’t know if we’re reading the same article? The linked one states very plainly:

”Idempotency is about the effect

An operation is idempotent if applying it once or many times has the same intended effect.”

show 2 replies
raffael_detoday at 11:04 AM

> Send the same payment twice and one of them should respond "payment already exists".

You are hiding the relevant complexity in the term "same". What is here the same? I mean, if accidentally buy only 1 instead of two items of a product and then buy afterwards again 1 item. How is this then the same or not the same payment?

show 1 reply
cocototoday at 10:04 AM

In your example, idempotency means same request + same state = same response. State becomes part of the request, that’s why it is hard.

show 1 reply