public static <T> CompletableFuture<T> orTimeout(CompletableFuture<T> future, Duration duration) {
    final CompletableFuture<T> timeout = failAfter(duration);
    return future.applyToEither(timeout, Function.identity());
  }
Times the given future out after the timeout.
@param <T> type of the given future
@param future to time out
@param duration Duration after which future is timed out
@return The timeout enriched future
ambry-commons/src/main/java/com/github/ambry/commons/FutureUtils.java