b64b54c74e
## Summary The RBAC and SSO auth plugins can own their own database client, but they could only read `DATABASE_URL`, so every connection they opened landed on the primary. The host webapp now resolves writer and read-replica URLs from its env (the same fallback chain its own Prisma clients use: control-plane URL first, then the default) and passes them to the plugins at create time via a shared `PluginDatabaseConfig`, along with separate connection limits for writes (default 2) and reads (default 5, tunable via `RBAC_DATABASE_*_CONNECTION_LIMIT` and `SSO_DATABASE_*_CONNECTION_LIMIT`). A plugin can then route hot-path reads (per-request auth checks, login routing) to the read replica and keep only rare mutations on the primary. With no replica configured, or no plugin installed, nothing changes: the OSS fallback ignores the new option and keeps reading through the Prisma clients it is already given. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
16 lines
692 B
TypeScript
16 lines
692 B
TypeScript
// Database connections for a plugin that owns its own client. The host
|
|
// resolves the URLs from its env so the plugin follows the same
|
|
// writer/replica topology the host uses. Shared by every plugin contract
|
|
// that carries a `database` section.
|
|
export type PluginDatabaseConfig = {
|
|
// Primary (writer) connection URL. Mutations and read-your-writes
|
|
// management reads run here.
|
|
writerUrl: string;
|
|
// Read-replica URL for the per-request auth reads. Omitted → those reads
|
|
// share the writer connection.
|
|
readerUrl?: string;
|
|
// Per-process pool sizes. Omitted → plugin defaults (writer 2, reader 5).
|
|
writerConnectionLimit?: number;
|
|
readerConnectionLimit?: number;
|
|
};
|