Object

io.fsq.common.concurrent

Futures

Related Doc: package concurrent

Permalink

object Futures

Handy helpers for dealing with Futures.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Futures
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class FilledTimeoutException extends TimeoutException

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val SentinelElement: StackTraceElement

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def awaitSuccessfulWithinTimeout[A](futures: Seq[Future[A]], timeout: Duration, onFailure: (Throwable) ⇒ Unit = _ => ())(implicit timer: Timer, caller: StackElement): Seq[A]

    Permalink
  7. def awaitWithDefault[T, U <: T](f: Future[T], timeout: Duration, timeoutDefault: ⇒ U): T

    Permalink

    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.

  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def groupedCollect[T, U](params: Iterable[T], limit: Int)(f: (T) ⇒ Future[U]): Future[Seq[U]]

    Permalink

    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.

  14. def groupedCollectWithBatch[T, U](params: Iterable[T], batchSize: Int, maxFutures: Int)(f: (Iterable[T]) ⇒ Future[U]): Future[Seq[U]]

    Permalink

    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.

  15. def groupedExecute[T](params: Iterable[T], limit: Int)(f: (T) ⇒ Future[Unit]): Future[Unit]

    Permalink

    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.

  16. def groupedTry[T, U](params: Iterable[T], limit: Int)(f: (T) ⇒ Future[U]): Future[Seq[Try[U]]]

    Permalink

    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.

  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. def runYieldInPool(pool: FuturePool): PoolJumper

    Permalink

    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

  23. def safeReturnFuture[T](func: ⇒ Future[T]): Future[T]

    Permalink

    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

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def time[T](futureFunc: ⇒ Future[T]): Future[(T, Int)]

    Permalink

    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.

  26. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  27. def unzip[A, B, C, D](future: Future[(A, B, C, D)]): (Future[A], Future[B], Future[C], Future[D])

    Permalink

    Unpack a future whose result is a tuple into a tuple of futures

  28. def unzip[A, B, C](future: Future[(A, B, C)]): (Future[A], Future[B], Future[C])

    Permalink

    Unpack a future whose result is a tuple into a tuple of futures

  29. def unzip[A, B](future: Future[(A, B)]): (Future[A], Future[B])

    Permalink

    Unpack a future whose result is a tuple into a tuple of futures

  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. def where[T](cond: Boolean, f: ⇒ Future[T]): Future[Option[T]]

    Permalink

    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

  34. def withTimeout[T](future: Future[T], timer: Timer, defaultValue: T, timeout: Duration, onTimeoutFunc: Option[() ⇒ Unit] = None): Future[T]

    Permalink

    If the future doesn't return within the duration, then call onFailureOption and returns the default value instead

  35. def withTimeoutThrow[T](future: Future[T], timer: Timer, timeout: Duration, errorMessage: String, onTimeoutFunc: Option[() ⇒ Unit] = None): Future[T]

    Permalink

    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

  36. def within[T](f: Future[T], timer: Timer, timeout: Duration)(implicit caller: StackElement): Future[T]

    Permalink
  37. def within[T](f: Future[T], timeout: Duration)(implicit timer: Timer, caller: StackElement): Future[T]

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped