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

Function makeDbHandle

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

Source from the content-addressed store, hash-verified

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