We've been recently wondering internally what's the better way of defining DB connections within plumber API:
At the top of the script before any endpoint is defined - this way we're sparing some time on each call and the connection is shared, but isn't there a performance issue attached to this because a connection is always left open? Should we perhaps use
poolhere similarly like in shiny apps?
Within each respective endpoint - results in each call being slightly longer, but at the end of end of it we can disconnect and make sure no open connections are left
What's your experience and advice on that? Thank you!