thrifty
thrifty copied to clipboard
RPC method timeouts
We need them.
Proposed api for generated methods:
Thrift:
service FooService {
i32 bar(1: string arg)
}
corresponding Java:
public interface FooService {
int bar(String arg);
int bar(String arg, long timeout, TimeUnit unit);
}
Timeouts would be communicated via ServiceMethodCallback#onError(Throwable)
- likely via a java.util.concurrent.TimeoutException
.
The downside being, of course, that the number of service methods doubles. On the other hand, such methods are typically a small portion of the overall number of generated methods, so it may not be so impactful.
We could take inspiration here from Apache, which uses a TreeSet of timeouts and just iterates through it on each IO loop - timeouts aren't guaranteed to fire at the expiration time (or ever), but better than nothing?