The underlying thrift Ruby library raises TransportException under a variety of circumstances:
From thrift's socket.rb:
raise TransportException.new(TransportException::NOT_OPEN, "Connection timeout to #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out writing #{str.length} bytes to #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, e.message)
raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out reading #{sz} bytes from #{@desc}")
raise TransportException.new(TransportException::NOT_OPEN, e.message)
raise TransportException.new(TransportException::UNKNOWN, "Socket: Could not read #{sz} bytes from #{@desc}")
The type of transport exception is a property of the exception instance (NOT_OPEN, TIMED_OUT, or UNKNOWN). Currently thrift_client provides the ability to retry only at the level of an exception class (e.g. TransportException). For non-idempotent requests, TIMED_OUT and UNKNOWN are not safe to retry, but NOT_OPEN should be safe. An ideal solution would be to have the Ruby thrift library itself raise subclasses of TransportException. In the interim, does this seem like a reasonable retry strategy to add to thrift_client? If so, I'm happy to do the implementation but would like some input on a good interface for configuring ThriftClient.
Some ideas I had:
- Add a new top-level option that lets users give a block to determine whether the exception should be retried
- Don't add any new options, but have thrift_client instead convert
Thrift::TransportException to ThriftClient::TransportException::NotOpen, ThriftClient::TransportException::TimedOut, and ThriftClient::TransportException::Unknown all of which subclass Thrift::TransportException, preserving existing behavior.
The underlying
thriftRuby library raisesTransportExceptionunder a variety of circumstances:From thrift's socket.rb:
The type of transport exception is a property of the exception instance (
NOT_OPEN,TIMED_OUT, orUNKNOWN). Currentlythrift_clientprovides the ability to retry only at the level of an exception class (e.g.TransportException). For non-idempotent requests,TIMED_OUTandUNKNOWNare not safe to retry, butNOT_OPENshould be safe. An ideal solution would be to have the Ruby thrift library itself raise subclasses of TransportException. In the interim, does this seem like a reasonable retry strategy to add tothrift_client? If so, I'm happy to do the implementation but would like some input on a good interface for configuring ThriftClient.Some ideas I had:
Thrift::TransportExceptiontoThriftClient::TransportException::NotOpen,ThriftClient::TransportException::TimedOut, andThriftClient::TransportException::Unknownall of which subclass Thrift::TransportException, preserving existing behavior.