SyliusResourceBundle icon indicating copy to clipboard operation
SyliusResourceBundle copied to clipboard

"Closable" HTTP client instance

Open kachayev opened this issue 5 years ago • 0 comments

In some cases, you need to be able to clean up all resources allocated by the HTTP client: close all open connections, shutdown appropriate threads etc. It's useful and desirable e.g. when your application has some kind of lifecycle management or when implementing a library that targets to be a good citizen for your JVM.

All of that is kinda tricky with Aleph, as we do not have any specific notion of "client instance" at all, at least in a way we do for the server. By default, HTTP request goes to a default shared connections pool and operates on shared Netty's threads group. But we can expose another API that creates a reified Closable instance that you can use to call .close when necessary (like we do to shut down a server), uses provided instance of a connection pool or newly created one (but never shared), spawns separate Netty's group to shutdown it when necessary.

kachayev avatar Dec 16 '18 18:12 kachayev