Scala Finagle-将ClientBuilder()升级到新的API版本
我有一个Scala Play-Finagle和ElasticSearch的项目 我使用的是旧版本API的欺骗客户端,如下所示:Scala Finagle-将ClientBuilder()升级到新的API版本,scala,playframework,finagle,Scala,Playframework,Finagle,我有一个Scala Play-Finagle和ElasticSearch的项目 我使用的是旧版本API的欺骗客户端,如下所示: val client = ClientBuilder() .codec(Http) .hosts("localhost:10000,localhost:10001,localhost:10003") .hostConnectionLimit(1) .build() val client = Http.newService("localhost:1000
val client = ClientBuilder()
.codec(Http)
.hosts("localhost:10000,localhost:10001,localhost:10003")
.hostConnectionLimit(1)
.build()
val client = Http.newService("localhost:10000,localhost:10001")
这是我的密码:
工作正常,但现在我想将代码升级到新的API版本,如下所示:
val client = ClientBuilder()
.codec(Http)
.hosts("localhost:10000,localhost:10001,localhost:10003")
.hostConnectionLimit(1)
.build()
val client = Http.newService("localhost:10000,localhost:10001")
我的代码的新版本如下:
但是,现在我的项目没有编译,这一行(111)有一个错误:
111:val client=clientFactory.apply()()
我不知道如何修理它
我改变这一点:
val clientFactory: ServiceFactory[HttpRequest, HttpResponse] = ClientBuilder()
.codec(Http())
.hosts(hosts)
.tcpConnectTimeout(1.second)
.hostConnectionLimit(1)
.buildFactory()
httpResponse.onSuccess{
response =>
Logger.debug("Received response: " + response)
client.close()
}.onFailure{ err: Throwable =>
Logger.error(err.toString)
client.close()
}
为此:
val clientFactory: Service[HttpRequest, HttpResponse] = Http.newService(hosts)
httpResponse.onSuccess{
response =>
Logger.debug("Received response: " + response)
}.onFailure{ err: Throwable =>
Logger.error(err.toString)
}
我认为:
val client = clientFactory.apply()()
我要改变这一点:
val clientFactory: ServiceFactory[HttpRequest, HttpResponse] = ClientBuilder()
.codec(Http())
.hosts(hosts)
.tcpConnectTimeout(1.second)
.hostConnectionLimit(1)
.buildFactory()
httpResponse.onSuccess{
response =>
Logger.debug("Received response: " + response)
client.close()
}.onFailure{ err: Throwable =>
Logger.error(err.toString)
client.close()
}
为此:
val clientFactory: Service[HttpRequest, HttpResponse] = Http.newService(hosts)
httpResponse.onSuccess{
response =>
Logger.debug("Received response: " + response)
}.onFailure{ err: Throwable =>
Logger.error(err.toString)
}
问题的原因是:
client.close()
因为关闭连接您得到的错误是什么?没有足够的参数用于类服务中的方法apply:(请求:org.jboss.netty.handler.codec.http.HttpRequest)com.twitter.util.Future[org.jboss.netty.handler.codec.http.HttpResponse]。[错误]未指定值参数请求。