Support for Scala Future's #249
Comments
Twitter's bijection library has methods for converting between the two. Does that help? |
Not that much, native support would be way better, however in the near future this will be easier if finatra would implement the Java interfaces that scala.concurrent.Future's will use in higher scala versions. |
Finatra is built on top of Twitter's Finagle and therefore uses Twitter's com.twitter.util.Future. As such, we have no plans at this time to move to natively supporting Scala's Future (introduced in Scala 2.10). There may be a more holistic movement to support this in Twitter's stack in the future but for now targeted use of the bijection library is probably the way to go when/if you need to convert between the two Futures. Also in your code example, there does not seem to be a reason for you to use a Future (of either type) here and you are not required to wrap your responses in a Future. See this section on Responses in Finatra for more information. For your example you could just use the ResponseBuilder. E.g.,: import com.twitter.finagle.httpx.{Response, Status, Request}
import com.twitter.finatra.http.Controller
import com.twitter.finatra.http.response.ResponseBuilder
class HelloWorldController @Inject() (
response: ResponseBuilder) extends Controller {
get("/hi") { request: Request =>
response.ok("Hello")
}
} Thanks! |
Hello, currently it would be great if scala also has support for scala native future's.
Currently If I do the following
I will get the future.toString instead of the content of the file (
scala.concurrent.impl.Promise$DefaultPromise@b2082d3
), which is really aweful, especially when you want to use finatra with other scala code which using scala.concurrent.Future'sThe text was updated successfully, but these errors were encountered: