Repository metrics
- Stars
- (1,311 stars)
- PR merge metrics
- (Avg merge 1d 10h) (2 merged PRs in 30d)
Description
Issue by joearasin Thursday Feb 25, 2016 at 23:32 GMT Originally opened as https://github.com/akka/akka/issues/19884
If I run code that looks like:
object Test extends App {
implicit val system = ActorSystem()
implicit val mat: ActorMaterializer = ActorMaterializer()
implicit val ec = mat.executionContext
val result: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://www.google.com"))
result.flatMap { case response: HttpResponse =>
Unmarshal(response.entity).to[String]
}.flatMap{ case body: String =>
println(body)
system.terminate()
}.onFailure { case e: Throwable =>
println(e)
println("Something went wrong")
}
}
It works, but I get a [ERROR] [02/25/2016 18:13:41.930] [default-akka.actor.default-dispatcher-11] [akka.actor.ActorSystemImpl(default)] Outgoing request stream error (akka.stream.AbruptTerminationException)
This can be avoided if I shutdown the connection pool.
When attempting to build an API client that uses Akka-HTTP internally, I'm trying to figure out what the proper way to either handle the pool internally, or expose something that makes it clear to the calling code that something was opened, and thus needs to be closed, or maybe the error shouldn't occur altogether.
Ideally, I want to have an API client that looks something like:
class APIClient(????) {
def getResults: Future[FooServiceResult] = {
Http().singleRequest(...) // How do I ensure the pool that is making these calls gets closed
}
}