Description
I have a question regarding the usage of the ClientSession API. While reviewing the documentation, I noticed that it's not explicitly stated whether it’s intended to be a long-lived or short-lived session. I’m wondering if it’s recommended to recreate the session per usage, or if it’s better to wrap it in an Arc and share it across the application.
Additionally, I’m curious about the cost of creating a ClientSession—is it inexpensive to create (similar to Tokio tasks), or is it something that should be done more cautiously?
For example, if I were using a ClientSession inside a loop, what would be the ideal approach? Should the session be created once and reused, or would it be better to recreate it on each iteration?
I took a look at the source code and it seems like creating the session might be relatively cheap, but I would appreciate some official guidance on this for more confidence in how to handle it.
Thanks so much for any insights you can provide!