I am building a fastapi project following a controller, manager and repo layers. My db connection and session is initialized and injected into each controller on the first request. It means my each controller is going to have only one session for all the endpoints in it. Is it the good way of doing it?
The other way of doing it is to make a new session for each request and fastapi dependency management will gracefully close the session on completion of request.
Actually, I was tired of using Depends() in each path function, so injecting the session once in the controller looks better. But I don't know will it work better in case of concurrent requests?