0

I have a project with Scala Play - Finagle and ElasticSearch

I am using a Finagle client with the old version of the API, like this:

val client = ClientBuilder()
  .codec(Http)
  .hosts("localhost:10000,localhost:10001,localhost:10003")
  .hostConnectionLimit(1)
  .build()

Here is my code:

https://gist.github.com/hectorgool/f217d16e2c15b122d7a7

and works fine, but now i want to upgrade my code to a new APIs version, like this:

val client = Http.newService("localhost:10000,localhost:10001")

The new version of my code is here:

https://github.com/hectorgool/es-client/blob/master/app/lib/FinagleClient.scala

But, now my project does not compile, I have an error with this line(111):

111: val client = clientFactory.apply()()

I don't know how to fix it

Sean Vieira
  • 155,703
  • 32
  • 311
  • 293
Sanx
  • 223
  • 1
  • 6
  • 17
  • What is the error you are getting? – Sean Vieira May 11 '15 at 01:24
  • not enough arguments for method apply: (request: org.jboss.netty.handler.codec.http.HttpRequest)com.twitter.util.Future[org.jboss.netty.handler.codec.http.HttpResponse] in class Service. [error] Unspecified value parameter request. – Sanx May 11 '15 at 11:31

1 Answers1

0

Solved

I change this:

  val clientFactory: ServiceFactory[HttpRequest, HttpResponse] = ClientBuilder()
    .codec(Http())
    .hosts(hosts)
    .tcpConnectTimeout(1.second)
    .hostConnectionLimit(1)
    .buildFactory() 

for this:

val clientFactory: Service[HttpRequest, HttpResponse] = Http.newService(hosts) 

I sumprime this:

val client = clientFactory.apply()()

And i change this:

httpResponse.onSuccess{
  response =>
    Logger.debug("Received response: " + response)
    client.close()
}.onFailure{ err: Throwable =>
    Logger.error(err.toString)      
    client.close()
}

for this:

httpResponse.onSuccess{
  response =>
    Logger.debug("Received response: " + response)
}.onFailure{ err: Throwable =>
    Logger.error(err.toString)      
}

the cause of the problem is:

client.close()

because closing the connections

Sanx
  • 223
  • 1
  • 6
  • 17