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

Function makeDbHandle

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

Source from the content-addressed store, hash-verified

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