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

Function makeDbHandle

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

Source from the content-addressed store, hash-verified

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