finagletwitter-finagle

Server .codec(Http()) not working as specified in example code


I am attempting to try out Finagle for the first time. I am new to Scala, so this question may seem easy to many of you.

I pulled 6.10.1-SNAPSHOT from GitHub, and attempted to implement the Robust Server example shown in the docs. The imports were not entirely clear to me, and I got all of them working except one. Note in the code below that there is one import that has an error along with one call to Http() which also has an error.

import com.twitter.finagle.http.Http

def main(args: Array[String]) {
    val handleExceptions = new HandleExceptions
    val authorize = new Authorize
    val respond = new Respond

    val myService: Service[HttpRequest, HttpResponse]
        = handleExceptions andThen authorize andThen respond

    val server: Server = ServerBuilder()
    .name("myService")
    .codec(Http()) // Error on this call to Http()
    .bindTo(new InetSocketAddress(8080))
    .build(myService)
}

Solution

  • The guide that you're following (I'm assuming this one) is quite outdated. The new docs here http://twitter.github.io/scala_school/finagle.html should be better (although the examples still aren't great)

    It looks like they moved the HTTP codec to com.twitter.finagle.Http