Description
Hey guys, do you have any recommendations on how to approach this task?
I need to manage a pool of connections in a multi-tenancy environment, means I have multiple DBs to talk to. Since I cannot afford creating a new Db connection upon each request, I have to create a pool of connections.
The way how DB connection is meant to be created is to:
- conn, err := graphHTTP.NewConnection(...)
- c, err := graphDriver.NewClient(...)
- db, err := p.cl.Database(...)
Implementation of the #3 uses a copy of the conn from #1. What it means to me is that even if I maintain my own pool of the db objects, every single one will hold a copy of the identical connections (in fact it's a connection pool). Since Database constructor is defined as private (newDatabase), even if I want to write my own implementation of #3 (with a pointer to the conn), I cannot bypass it.
Any suggestion on how to address the issue?