Future Gotchas¶
c.t.util.Future
vs. scala.concurrent.Future
¶
Finatra – like other frameworks based on Twitter’s Finagle library – uses the TwitterUtil c.t.util.Future class.
Twitter’s com.twitter.util.Future is similar to, but predates Scala’s scala.concurrent.Future (introduced in Scala 2.10 and later backported to Scala 2.9.3) and is not compatible without using a Bijection to transform one into the other.
It is important to remember that the Finatra framework uses and expects c.t.util.Future.
Finatra will attempt to perform a bijection for you if your Controller route callback returns a scala.concurrent.Future
. However, note that this bijection may not be ideal in all cases and you may wish to do the conversion yourself directly in your Controller.
For more information on the Twitter Bijection library it is highly recommended that you read the Bijection README.
For more information on converting between c.t.util.Future
and scala.concurrent.Future
see this documentation from the TwitterUtil project (which includes a simple example).