History

mac connections

Rhys Sullivan committed 8 months ago

Commit 67c45121 parent 29e4b722 files · +20 −1Browse files

Unified · Split

2 files
  1. apps/web/app/api/control-plane/[...path]/route.ts +5 −0
  2. packages/persistence-sql/src/sql-internals.ts +15 −1
apps/web/app/api/control-plane/[...path]/route.ts+5−0
@@ -105,6 +105,11 @@ const handle = async (request: NextRequest, context: RouteContext): Promise<Resp · 104 unmodified lines
105 105
106 return runtime.handleControlPlane(applyPrincipalHeaders(controlPlaneRequest, principal));106 return runtime.handleControlPlane(applyPrincipalHeaders(controlPlaneRequest, principal));
107 } catch (cause) {107 } catch (cause) {
108 console.error("[control-plane] request failed", {
109 method: request.method,
110 path: request.nextUrl.pathname,
111 cause,
112 });
108 return storageErrorResponse("control-plane.request", cause);113 return storageErrorResponse("control-plane.request", cause);
109 }114 }
110};115};
packages/persistence-sql/src/sql-internals.ts+15−1
@@ -67,6 +67,20 @@ type SqlRuntime = { · 66 unmodified lines
67 close: () => Promise<void>;67 close: () => Promise<void>;
68};68};
69 69
70const resolvePostgresMaxConnections = (): number => {
71 const configured = process.env.CONTROL_PLANE_POSTGRES_MAX_CONNECTIONS
72 ?? process.env.POSTGRES_MAX_CONNECTIONS;
73
74 if (configured) {
75 const parsed = Number.parseInt(configured, 10);
76 if (Number.isFinite(parsed) && parsed > 0) {
77 return parsed;
78 }
79 }
80
81 return process.env.NODE_ENV === "production" ? 1 : 10;
82};
83
70const sanitizePostgresUrl = (value: string): string => {84const sanitizePostgresUrl = (value: string): string => {
71 try {85 try {
72 const parsed = new URL(value);86 const parsed = new URL(value);
@@ -108,7 +122,7 @@ const createPostgresRuntime = async ( · 35 unmodified lines
108): Promise<SqlRuntime> => {122): Promise<SqlRuntime> => {
109 const client = postgres(sanitizePostgresUrl(databaseUrl), {123 const client = postgres(sanitizePostgresUrl(databaseUrl), {
110 prepare: false,124 prepare: false,
111 max: 10,125 max: resolvePostgresMaxConnections(),
112 ...(applicationName ? { connection: { application_name: applicationName } } : {}),126 ...(applicationName ? { connection: { application_name: applicationName } } : {}),
113 });127 });
114 128

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t