Created
September 3, 2019 17:43
-
-
Save adleong/80b24cf83847d690e2106e3b84f1c370 to your computer and use it in GitHub Desktop.
simple scala client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Simple scala client */ | |
import $ivy.`com.twitter::finagle-http:6.44.0` | |
import $ivy.`io.buoyant::finagle-h2:1.1.0` | |
import com.twitter.conversions.time._ | |
import com.twitter.finagle.{Status => _, _} | |
import com.twitter.finagle.buoyant.h2._ | |
import com.twitter.finagle.buoyant.H2 | |
import com.twitter.io.Buf | |
import com.twitter.util._ | |
import com.twitter.finagle.util.DefaultTimer | |
import com.twitter.logging._ | |
@main | |
def main(host: String, port: Int) = { | |
Logger.configure(List(LoggerFactory( | |
node = "", | |
level = Some(Level.TRACE), | |
handlers = List(ConsoleHandler()) | |
))) | |
implicit val timer = DefaultTimer.twitter | |
val client = H2.client.newClient(Name.bound(Address(host, port)), "client") | |
val service = Await.result(client()) | |
for (i <- 1.to(10)) { | |
val s = Stream() | |
println("initiating request") | |
val req = Request("http", Method.Get, "foo", "/", s) | |
val rspF = service(req) | |
val rsp = Await.result(rspF) | |
println(rsp.status) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment