go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

add idempotency key

Open idelvall opened this issue 2 years ago • 3 comments

Adds an idempotency key to the headers sent by the requests and its retries so the server can use this header to avoid processing multiple times a non-idempotent implementation.

Idempotency keys are unique tokens that you submit as a request header, that guarantee that only one resource will be created regardless of how many times a request is sent to us.

idelvall avatar Oct 13 '23 16:10 idelvall

This seems like a reasonable idea, but couldn't it just be another interceptor? Why does it need to be part of the retry logic? Also please add some tests.

Hi @johanbrandhorst, yes I considered that option, but my reasoning was that given that non-idempotent RPCs should not be retried, this is something that falls into the library scope.

Happy to add those tests if you think the change is worth it.

idelvall avatar Oct 16 '23 17:10 idelvall

Ah, you mean that the use of the retry interceptor implies that the request must be idempotent? I suppose I follow that logic.

johanbrandhorst avatar Oct 16 '23 22:10 johanbrandhorst

Yes, please do add the tests and fix the build, thanks

johanbrandhorst avatar Oct 16 '23 22:10 johanbrandhorst