The Scala HTTP client
Build on top Akka HTTP Client to support multiple hosts and different selector strategies and retry strategies
implicit val system = ActorSystem()
import system.dispatcher
implicit val materializer = ActorMaterializer()
val servers = Seq(Uri(s"http://192.168.0.100:8080"), Uri(s"http://192.168.0.101:8080"))
val httpClient = new HttpMultipleHostPool(
servers,
bufferSize = 10,
new InfiniteStrategy(),
OverflowStrategy.dropBuffer
) with WeightedRoundRobinSelector {
override val defaultWeight: Int = 100
override val decrementBy: Int = 30
}
val response = httpClient.sendRequest(HttpRequest(uri = "/query"))
val result = Await.result(response, 10 seconds)
println(s"Get Response: $result")