Lucid: Add support for Google Cloud SQL Node connector #4508
markgidman-rad
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Per this post, @google-cloud/cloud-sql-connector is now the preferred/approved way to connect NodeJS to PostgreSQL, MySQL and SQL Server on Google Cloud SQL. The connector has been shown to work with knex already. But if I'm reading the lucid code correctly, it doesn't, and maybe can't work without an enhancement because when the database provider is registered, it reads the config synchronously and the Cloud Connector uses an async process to gather connection details at runtime.
Cloud Connector snippet from the documentation showing the async call to get the options at runtime:
I believe if this feature were implemented, it would also handle this issue Add support for Unix Path on Postgres databases for GCP Cloud SQL #980. When FrenchMajesty submitted that request, the Cloud SQL Node Connector had not been released and socketPath was the recommended solution. The connector is easier to use and is now the recommended solution.
I don't know if it's possible to use a Config Provider to deliver the database config asynchronously. At first, I thought that might be a solution so I tried implementing it that way but it didn't work. Unless I'm missing something, it won't work because the database config is read synchronously while the
emitter
andlogger
use theresolver
.If I'm missing something and a Config Provider should work, please let me know. As FrenchMajesty mentioned, this is the only way to connect to Google Cloud SQL from App Engine or Cloud Run. It's a significant roadblock.
Thanks for any help you can provide.
Mark
Beta Was this translation helpful? Give feedback.
All reactions