Package

io.fsq.common

concurrent

Permalink

package concurrent

Visibility
  1. Public
  2. All

Type Members

  1. final class DefaultPoolJumper extends PoolJumper

    Permalink
  2. final class FutureOption[+A] extends AnyVal

    Permalink

    A monadic wrapper around the common case of Future[Option[A]].

    A monadic wrapper around the common case of Future[Option[A]]. Allows you to use for-comprehensions around Future[Option[A]] without needing to special case each None case.

    Example:

    val result: Future[Option[Venue]] = (for { user <- FutureOption(services.futureDb.fetchOne(Q(User).where(_.id eqs 32))) tip <- FutureOption(services.futureDb.fetchOne(Q(Tip).where(_.userid eqs user.id))) venue <- FutureOption(services.futureDb.fetchOne(Q(Venue).where(_.id eqs tip.venueid))) if !venue.isHome } yield venue).resolve

    Example 2: val sixteenFOpt = FutureOption(Future.value(Some(16))) for { s <- sixteenFOpt } { println(s) } This will output "16".

    FutureOption is a value class. http://docs.scala-lang.org/overviews/core/value-classes.html

  3. final class FutureOutcome[+S, +F] extends AnyVal

    Permalink

    Inspired by io.fsq.common.concurrent.FutureOption, this is a monadic wrapper around Future[Outcome[S, F]] so you can easily combine Future[S], Option[S], Outcome[S, F], etc.

    Inspired by io.fsq.common.concurrent.FutureOption, this is a monadic wrapper around Future[Outcome[S, F]] so you can easily combine Future[S], Option[S], Outcome[S, F], etc. into a for yield.

    Example:

    val result: Future[Outcome[Venue, String]] = (for { userid <- FutureOutcome.lift(msg.useridOption, "no-userid") user <- FutureOutcome.lift(services.futureDb.fetchOne(Q(User).where(_.userid eqs userid)), "no-user") venue <- FutureOutcome(services.foo.bar(user)) // where bar returns Future[Outcome[Venue, String]] _ <- FutureOutcome.failWhen(venue.isHomeOrOffice, "home-or-office-venue") } yield venue).resolve

  4. trait PoolJumper extends AnyRef

    Permalink

    PoolJumper is a utility used in a for comprehension of futures that can control the execution context of the yield block

    PoolJumper is a utility used in a for comprehension of futures that can control the execution context of the yield block

    PoolJumper implements the interface for Futures.runYieldInPool, used in the following example

    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

  5. class StableEvent[T] extends Event[T]

    Permalink

    An com.twitter.util.Event that only notifies if the observed value actually changes.

Value Members

  1. object FutureOption

    Permalink
  2. object FutureOutcome

    Permalink
  3. object Futures

    Permalink

    Handy helpers for dealing with Futures.

  4. object StableVar

    Permalink

Ungrouped