2 ms·
In your example, idempotency means same request + same state = same response. State becomes part of the request, that’s why it is hard.
by cocoto 5mo ago
In your example, idempotency means same request + same state = same response. State becomes part of the request, that’s why it is hard.
- shiandow 5mo agoThat's just deterministic behaviour. For idempotency you literally just want f(state) = f(f(state)). Whether you achieve this by just doing the same thing twice (no external effects) or doing the thing exactly once (if you do have side effects) is not important. But if you have side effects and need something to happen exactly once it seems a lot more useful to communicate this, rather than pretending you did the thing.
- huflungdung 5mo ago[dead]
- adrianmsmith 5mo ago> But if you have side effects and need something to happen exactly once it seems a lot more useful to communicate this, rather than pretending you did the thing. I think it depends on whether the sender needs to know whether the thing was done during the request, or just needs to know that the thing was done at all. If the API is to make a purchase then maybe all the caller really needs to know is "the purchase has been done", no matter whether it was done this time or a previous time. And in terms of a caller implementing retry logic, it's easier for the caller to just retry and accept the success response the second time (no matter if it was done the second time, or actually done the first time but the response got lost triggering the retry).
- deleted 5mo ago[deleted]