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

Function makeDbHandle

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

Source from the content-addressed store, hash-verified

147 * server can preserve session-local protocol state across requests.
148 */
149const makeDbHandle = (options: {
150 readonly idleTimeout: number;
151 readonly maxLifetime: number;
152}): CloudSessionDbHandle => {
153 const sql = postgres(resolveConnectionString(), {
154 max: 1,
155 idle_timeout: options.idleTimeout,
156 max_lifetime: options.maxLifetime,
157 connect_timeout: 10,
158 fetch_types: false,
159 prepare: true,
160 onnotice: () => undefined,
161 });
162 return {
163 sql,
164 db: drizzle(sql, { schema: combinedSchema }) as DrizzleDb,
165 // oxlint-disable-next-line executor/no-promise-catch -- boundary: postgres.js close is best-effort during DO/runtime cleanup
166 end: () => sql.end({ timeout: 0 }).catch(() => undefined),
167 };
168};
169
170const makeEphemeralDb = (): CloudSessionDbHandle =>
171 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