Open edosrecki opened 10 months ago
Thanks for opening this issue @edosrecki! I don't have the bandwith right now to contribute to atdatabases but if anyone is willing to take a try at adding the support to the stream
parameter, these are the references to the places I believe have to be tweaked:
Issue
Both
mysql2
andpg
clients support an optionalstream
config parameter (see references), which is either an existing stream, or a factory which creates a stream lazily. However,@databases
library does not acceptstream
parameter, and does not pass it to underlying drivers.Justification
stream
parameter allows a more flexible control of the socket connection creation. It supports a variety of setups such as secure socket connections that are used by cloud providers such as Google Cloud Platform. In references you can see how Google Cloud SQL Connector creates a stream factory which is used to connect to Google Cloud SQL instances (with password, or IAM authentication), secured by an ephemeral certificate.It would be beneficial for GCP users, who want to use
@databases
, if the library accepted thestream
parameter and passed it down to drivers.References
mysql2
: https://github.com/sidorares/node-mysql2/blob/a0e0e2fe2c115dc0246c52783fd29945ae01bf77/lib/connection.js#L67C2-L67C2pg
: https://github.com/brianc/node-postgres/blob/a84ebb3fe85edafb1b358965bdb5e3de58b12c5d/packages/pg/lib/connection.js#L19cloud-sql-nodejs-connector
: https://github.com/GoogleCloudPlatform/cloud-sql-nodejs-connector/blob/00e726f4f60f9c83fb816211d447013f6c0163e0/src/connector.ts#L185