Open
Description
I started experimenting with using PoolCluster
to manage pools to multiple databases, including distinguishing readonly from readwrite (i.e. primary and replicas) via aliases and wildcards. I ran into trouble for a few reasons:
- the example code given suggests that
cluster.of()
returns aPool
, when in fact it simply returns something that implementsgetConnection()
andquery()
; after reading other issues, this of course makes sense because with a selector likeREADONLY*
that naturally gives you an object that might represent N different pools - lack of explicit documentation here means I (and others) have had to infer this from testing and reading the source/issues
- we need access to the
Pool
objects, however, to use things like theconnection
event (to set SQL session modes), andacquire
/enqueue
(for deadlock tracking); given the design constraint onof()
, there needs to be another way to provide this access. Possibilities: - Allow passing full
Pool
objects toadd()
, not justPoolConfig
; then the caller could do any setup needed before putting them in the cluster - Allow an optional callback to
add()
which will be called with the resultingPool
- Emit a
pool
oradded
event, similar toconnection
fromPool
, that allows the listener to know when a newPool
has been created by the cluster and set listeners etc. on it - Allow passing event listeners in the config (would make sense as a larger design change, i.e. for all object types)
I know the documentation concerns have been raised before, but wanted to capture my thoughts on the other issues.
Metadata
Metadata
Assignees
Labels
No labels