Blocks on the future, until the future completes, or the timeout is reached.
Blocks on the future, until the future completes, or the timeout is reached. There are three possibilities: a) The future completes successfully, and its value is returned. b) The future times out, and default is returned. c) The future throws an exception, and then this call will throw.
Please consider using non-blocking future handling, such as .map, .flatMap, or .rescue instead of this function.
If we generate a large list of futures at once, we risk overloading the future pool.
If we generate a large list of futures at once, we risk overloading the future pool. This allows us to generate futures in small groups and chain them together. Maintains the order of the Iterable.
groupedCollectWithBatch performs the same operation as groupedCollect but does a .grouped on the input params first Effectively, you get up to limit Futures running over group items from params at any given time.
Like groupedCollect, but executes every future.
Like groupedCollect, but executes every future. If the executed futures have side effects, then this is what you want to do. If there is an exception, the resulting futures will still be executed. The returned Future will contain the first exception thrown.
Like groupedExecute, but exposes the results of each executed future as a Try.
Like groupedExecute, but exposes the results of each executed future as a Try. If your computations have side-effects, but you also want to know which sub-requests executed successfully, you can inspect each returned Try.
runs the yield block of a for comprehension in an explicit execution context
runs the yield block of a for comprehension in an explicit execution context
xF, yF might be finagle futures, runYieldInPool will run doBlockingWork in a safe execution context.
for { x <- xF y <- yF _ <- Futures.runYieldInPool(pool) } yield doBlockingWork
Run the func, but turn any Throwables thrown into a Future.exception so that later code can assume it is always dealing with a future
Returns a new Future whose return value will be a tuple of the value of
futureFunc
, and the number of milliseconds that elapsed between
calling time
and the completion of futureFunc
.
Returns a new Future whose return value will be a tuple of the value of
futureFunc
, and the number of milliseconds that elapsed between
calling time
and the completion of futureFunc
. Note that if you create
futureFunc
before wrapping it intime
, then the time returned might be
less than the actual amount of time that futureFunc
ran.
Unpack a future whose result is a tuple into a tuple of futures
Unpack a future whose result is a tuple into a tuple of futures
Unpack a future whose result is a tuple into a tuple of futures
A helper function for for-comprehensions.
A helper function for for-comprehensions. Useful for handling the common case where you do not want to proceed if a condition is false.
Ex:
val result: Future[Option[Int]] = for { likeCountOpt <- Futures.where(userSupportsLikes, fetchLikeCount()) } yield likeCountOpt
If the future doesn't return within the duration, then call onFailureOption and returns the default value instead
If the future doesn't return within the duration, then call onTimeoutFunc
If the future doesn't return within the duration, then call onTimeoutFunc
Calls onTimeoutFunc but still throws
Handy helpers for dealing with Futures.