A monadic wrapper around the common case of Future[Option[A]].
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
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
An com.twitter.util.Event that only notifies if the observed value actually changes.
Handy helpers for dealing with Futures.
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