MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeDbHandle

Function makeDbHandle

apps/cloud/src/mcp/session-durable-object.ts:125–144  ·  view source on GitHub ↗
(options: {
  readonly idleTimeout: number;
  readonly maxLifetime: number;
})

Source from the content-addressed store, hash-verified

123 * server can preserve session-local protocol state across requests.
124 */
125const makeDbHandle = (options: {
126 readonly idleTimeout: number;
127 readonly maxLifetime: number;
128}): CloudSessionDbHandle => {
129 const sql = postgres(resolveConnectionString(), {
130 max: 1,
131 idle_timeout: options.idleTimeout,
132 max_lifetime: options.maxLifetime,
133 connect_timeout: 10,
134 fetch_types: false,
135 prepare: true,
136 onnotice: () => undefined,
137 });
138 return {
139 sql,
140 db: drizzle(sql, { schema: combinedSchema }) as DrizzleDb,
141 // oxlint-disable-next-line executor/no-promise-catch -- boundary: postgres.js close is best-effort during DO/runtime cleanup
142 end: () => sql.end({ timeout: 0 }).catch(() => undefined),
143 };
144};
145
146const makeEphemeralDb = (): CloudSessionDbHandle =>
147 makeDbHandle({ idleTimeout: 0, maxLifetime: 60 });

Callers 2

makeEphemeralDbFunction · 0.85
openSessionDbMethod · 0.85

Calls 2

resolveConnectionStringFunction · 0.90
endMethod · 0.80

Tested by

no test coverage detected