I am writing a server end program using Twitter Finagle. I do not use the full Twitter server stack, just the part that allows asynchronous processing (so that future, function, etc.). I want Future objects to have timeouts, so I wrote the following:
Future<String> future = Future.value(some_input).flatMap(time_consuming_function1);
future.get(Duration.apply(5, TimeUnit.SECONDS));
time_consuming_function1works more than 5 seconds. But it futuredoes not expire after 5 seconds and waits until time_consuming_function1it finishes.
I think this is due to the fact that it future.get(timeout)only cares about how long futureit took to create, and not the entire chain of operations. Is there a way to timeout the entire chain of operations?
source
share