grpclib icon indicating copy to clipboard operation
grpclib copied to clipboard

GRPC Options (Retry specifically) support

Open artificial-aidan opened this issue 3 years ago • 3 comments

The official grpc client supports grpc service config and allows for client side retry (example. Is this something that could be done with an event? Or would retry have to be built into each client call.

artificial-aidan avatar Feb 26 '21 19:02 artificial-aidan

Currently such configuration is not implemented.

I probably saw somewhere that some people were trying to subclass the Channel class to override __connect__ method. This way you can implement your retry logic, but __connect__ method is not documented and not meant to be overridden, so there is no guarantee that this method wont change in the future versions. But this won't likely happen.

The only limitation here is that you can only catch connection errors, you wont be able to retry here on some specific status codes.

It is also possible to extend RecvTrailingMetadata event with a status code (have to be implemented in grpclib), which will give an ability to implement connection close on specific status codes.

vmagamedov avatar Feb 28 '21 15:02 vmagamedov

Missed this response somehow.

So is the suggestion to try and override __connect__ to handle connection errors, and then use RecvTrailingMetadata to cause a connection error on a specific status code?

artificial-aidan avatar Jun 08 '21 15:06 artificial-aidan

So is the suggestion to try and override __connect__ to handle connection errors

yes

use RecvTrailingMetadata to cause a connection error on a specific status code

this is optional, I actually don't remember why I mentioned this

vmagamedov avatar Jun 13 '21 20:06 vmagamedov