Make Prisma examples more production friendly #416
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: docs
Improvement to the documentation for an API.
Today our Prisma examples have a single
connect()
function that creates aConnector
,starts a local proxy listener, and then creates a
PrismaClient
.It returns the
PrismaClient
, and a function to close the client andConnector
for the userto call when done with database connections.
While this example works, it is not production friendly.
Ideally all connections to a single Cloud SQL instance should share a
Connector
and thelocal proxy, not create a new one for each database user.
cloud-sql-nodejs-connector/examples/prisma/postgresql/connect.ts
Lines 23 to 46 in 6040826
Solution is to move the
Connector
initialization andconnector.startLocalProxy
call out ofconnect()
, so that theConnector
can be shared across multipleconnect
invocations and across PrismaClients for different users.Related to #345
The text was updated successfully, but these errors were encountered: