go-grpc-middleware
go-grpc-middleware copied to clipboard
add idempotency key
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.
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.
Ah, you mean that the use of the retry interceptor implies that the request must be idempotent? I suppose I follow that logic.
Yes, please do add the tests and fix the build, thanks