@vibesdotdev/localdb 0.0.2 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -0
- package/README.md +123 -2
- package/dist/cli/commands/_shared.consumer.d.ts +1 -3
- package/dist/cli/commands/_shared.consumer.d.ts.map +1 -1
- package/dist/cli/commands/_shared.consumer.js +1 -11
- package/dist/cli/commands/_shared.consumer.js.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts +9 -3
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js +59 -45
- package/dist/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts +8 -3
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js +12 -10
- package/dist/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts +6 -3
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js +8 -7
- package/dist/cli/commands/pools/dev.localdb.pools.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts +13 -3
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js +66 -51
- package/dist/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.descriptor.js.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts +9 -3
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.d.ts.map +1 -1
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js +41 -29
- package/dist/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.js.map +1 -1
- package/dist/cli/inputs.d.ts +25 -0
- package/dist/cli/inputs.d.ts.map +1 -0
- package/dist/cli/inputs.js +81 -0
- package/dist/cli/inputs.js.map +1 -0
- package/dist/cli/types.d.ts +45 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +14 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/core/connection-pool.d.ts +204 -46
- package/dist/core/connection-pool.d.ts.map +1 -1
- package/dist/core/connection-pool.js +610 -101
- package/dist/core/connection-pool.js.map +1 -1
- package/dist/core/database.d.ts +243 -63
- package/dist/core/database.d.ts.map +1 -1
- package/dist/core/database.js +937 -203
- package/dist/core/database.js.map +1 -1
- package/dist/core/holders.d.ts +15 -0
- package/dist/core/holders.d.ts.map +1 -0
- package/dist/core/holders.js +4 -0
- package/dist/core/holders.js.map +1 -0
- package/dist/core/host-kinds.d.ts +22 -0
- package/dist/core/host-kinds.d.ts.map +1 -0
- package/dist/core/host-kinds.js +52 -0
- package/dist/core/host-kinds.js.map +1 -0
- package/dist/core/live-runtime.d.ts +17 -0
- package/dist/core/live-runtime.d.ts.map +1 -0
- package/dist/core/live-runtime.js +28 -0
- package/dist/core/live-runtime.js.map +1 -0
- package/dist/core/migration-registry.d.ts +115 -80
- package/dist/core/migration-registry.d.ts.map +1 -1
- package/dist/core/migration-registry.js +340 -199
- package/dist/core/migration-registry.js.map +1 -1
- package/dist/core/open-connection.d.ts +11 -0
- package/dist/core/open-connection.d.ts.map +1 -0
- package/dist/core/open-connection.js +70 -0
- package/dist/core/open-connection.js.map +1 -0
- package/dist/core/outcome.d.ts +21 -0
- package/dist/core/outcome.d.ts.map +1 -0
- package/dist/core/outcome.js +22 -0
- package/dist/core/outcome.js.map +1 -0
- package/dist/core/pool-api.d.ts +19 -0
- package/dist/core/pool-api.d.ts.map +1 -0
- package/dist/core/pool-api.js +59 -0
- package/dist/core/pool-api.js.map +1 -0
- package/dist/core/slow-statement.d.ts +81 -0
- package/dist/core/slow-statement.d.ts.map +1 -0
- package/dist/core/slow-statement.js +149 -0
- package/dist/core/slow-statement.js.map +1 -0
- package/dist/core/wal-policy.d.ts +86 -0
- package/dist/core/wal-policy.d.ts.map +1 -0
- package/dist/core/wal-policy.js +115 -0
- package/dist/core/wal-policy.js.map +1 -0
- package/dist/dev.localdb.cli-group.descriptor.d.ts +1 -1
- package/dist/dev.localdb.cli-group.descriptor.d.ts.map +1 -1
- package/dist/dev.localdb.context.descriptor.d.ts +15 -1
- package/dist/dev.localdb.context.descriptor.d.ts.map +1 -1
- package/dist/dev.localdb.context.descriptor.js +1 -1
- package/dist/dev.localdb.context.descriptor.js.map +1 -1
- package/dist/dev.localdb.context.impl.consumer.d.ts +12 -5
- package/dist/dev.localdb.context.impl.consumer.d.ts.map +1 -1
- package/dist/dev.localdb.context.impl.consumer.js +14 -5
- package/dist/dev.localdb.context.impl.consumer.js.map +1 -1
- package/dist/driver/sqlite-driver.base.d.ts +107 -0
- package/dist/driver/sqlite-driver.base.d.ts.map +1 -0
- package/dist/driver/sqlite-driver.base.js +426 -0
- package/dist/driver/sqlite-driver.base.js.map +1 -0
- package/dist/driver/sqlite-driver.d.ts +154 -0
- package/dist/driver/sqlite-driver.d.ts.map +1 -0
- package/dist/driver/sqlite-driver.js +103 -0
- package/dist/driver/sqlite-driver.js.map +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/localdb.client.descriptor.d.ts +10 -0
- package/dist/localdb.client.descriptor.d.ts.map +1 -0
- package/dist/localdb.client.descriptor.js +13 -0
- package/dist/localdb.client.descriptor.js.map +1 -0
- package/dist/localdb.client.impl.consumer.d.ts +11 -0
- package/dist/localdb.client.impl.consumer.d.ts.map +1 -0
- package/dist/localdb.client.impl.consumer.js +11 -0
- package/dist/localdb.client.impl.consumer.js.map +1 -0
- package/dist/localdb.plugin.d.ts +2 -2
- package/dist/localdb.plugin.d.ts.map +1 -1
- package/dist/localdb.plugin.js +58 -10
- package/dist/localdb.plugin.js.map +1 -1
- package/dist/location.d.ts +6 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +6 -0
- package/dist/location.js.map +1 -0
- package/dist/migrations/load-sql.d.ts +25 -21
- package/dist/migrations/load-sql.d.ts.map +1 -1
- package/dist/migrations/load-sql.js +91 -76
- package/dist/migrations/load-sql.js.map +1 -1
- package/dist/pool.d.ts +3 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +3 -0
- package/dist/pool.js.map +1 -0
- package/dist/schemas/api.d.ts +133 -59
- package/dist/schemas/api.d.ts.map +1 -1
- package/dist/schemas/api.js +1 -1
- package/dist/schemas/api.js.map +1 -1
- package/dist/schemas/migrations.d.ts +123 -0
- package/dist/schemas/migrations.d.ts.map +1 -0
- package/dist/schemas/migrations.js +55 -0
- package/dist/schemas/migrations.js.map +1 -0
- package/dist/schemas/pool.d.ts +27 -0
- package/dist/schemas/pool.d.ts.map +1 -0
- package/dist/schemas/pool.js +7 -0
- package/dist/schemas/pool.js.map +1 -0
- package/dist/schemas/sqlite-driver-base.d.ts +50 -0
- package/dist/schemas/sqlite-driver-base.d.ts.map +1 -0
- package/dist/schemas/sqlite-driver-base.js +2 -0
- package/dist/schemas/sqlite-driver-base.js.map +1 -0
- package/dist/testing/sqlite-driver-conformance.d.ts +42 -0
- package/dist/testing/sqlite-driver-conformance.d.ts.map +1 -0
- package/dist/testing/sqlite-driver-conformance.js +471 -0
- package/dist/testing/sqlite-driver-conformance.js.map +1 -0
- package/package.json +78 -104
- package/dist/core/error-context.d.ts +0 -2
- package/dist/core/error-context.d.ts.map +0 -1
- package/dist/core/error-context.js +0 -17
- package/dist/core/error-context.js.map +0 -1
- package/dist/core/runtime.d.ts +0 -3
- package/dist/core/runtime.d.ts.map +0 -1
- package/dist/core/runtime.js +0 -17
- package/dist/core/runtime.js.map +0 -1
- package/dist/localdb.cloud.plugin.d.ts +0 -17
- package/dist/localdb.cloud.plugin.d.ts.map +0 -1
- package/dist/localdb.cloud.plugin.js +0 -23
- package/dist/localdb.cloud.plugin.js.map +0 -1
- package/src/cli/commands/_shared.consumer.ts +0 -20
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.descriptor.ts +0 -20
- package/src/cli/commands/migrate/dev.localdb.migrate.cli-command.impl.consumer.ts +0 -97
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.descriptor.ts +0 -17
- package/src/cli/commands/namespaces/dev.localdb.namespaces.cli-command.impl.ts +0 -46
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.descriptor.ts +0 -16
- package/src/cli/commands/pools/dev.localdb.pools.cli-command.impl.ts +0 -37
- package/src/cli/commands/query/dev.localdb.query.cli-command.descriptor.ts +0 -21
- package/src/cli/commands/query/dev.localdb.query.cli-command.impl.consumer.ts +0 -69
- package/src/cli/commands/status/dev.localdb.status.cli-command.descriptor.ts +0 -20
- package/src/cli/commands/status/dev.localdb.status.cli-command.impl.consumer.ts +0 -93
- package/src/core/connection-pool.ts +0 -240
- package/src/core/database.ts +0 -419
- package/src/core/error-context.ts +0 -19
- package/src/core/migration-registry.ts +0 -321
- package/src/core/runtime.ts +0 -17
- package/src/dev.localdb.cli-group.descriptor.ts +0 -20
- package/src/dev.localdb.context.descriptor.ts +0 -13
- package/src/dev.localdb.context.impl.consumer.ts +0 -12
- package/src/index.ts +0 -28
- package/src/localdb.cloud.plugin.ts +0 -24
- package/src/localdb.plugin.ts +0 -43
- package/src/migrations/atlas/001-initial-schema.sql +0 -173
- package/src/migrations/atlas/002-lang-server-fields.sql +0 -12
- package/src/migrations/atlas/003-config-id-dedup.sql +0 -31
- package/src/migrations/atlas/004-fix-on-conflict-constraints.sql +0 -25
- package/src/migrations/atlas/005-diagnostics.sql +0 -66
- package/src/migrations/atlas/006-diagnostic-summaries.sql +0 -65
- package/src/migrations/atlas/007-diagnostic-slice.sql +0 -83
- package/src/migrations/load-sql.ts +0 -133
- package/src/schemas/api.ts +0 -92
|
@@ -7,78 +7,236 @@
|
|
|
7
7
|
* Features:
|
|
8
8
|
* - Singleton pattern per database path
|
|
9
9
|
* - Automatic WAL mode and busy timeout configuration
|
|
10
|
+
* - A bounded WAL (D-WAL, see `wal-policy.ts`): `journal_size_limit`; one
|
|
11
|
+
* non-blocking checkpoint attempt per idle window (TRUNCATE, falling back to
|
|
12
|
+
* RESTART after a busy attempt) with busy attempts backing off by whole
|
|
13
|
+
* windows; an attempt on release to zero references and at close; observed
|
|
14
|
+
* `(busy, log, checkpointed)` results with busy outcomes logged; and a bound
|
|
15
|
+
* on how long a transaction may stay open
|
|
10
16
|
* - Connection reuse across consumers
|
|
11
|
-
* -
|
|
17
|
+
* - Slow-statement reporting: a statement at or over `SLOW_STATEMENT_MS` on any
|
|
18
|
+
* pooled connection is recorded with its operation and table, and the tick
|
|
19
|
+
* reports it (see `slow-statement.ts`) — value-free, and never from the
|
|
20
|
+
* statement's own path
|
|
21
|
+
* - Explicit, host-owned cleanup
|
|
12
22
|
* - Connection statistics and monitoring
|
|
23
|
+
*
|
|
24
|
+
* The pool never deletes a raw `-wal` or `-shm` file.
|
|
25
|
+
*
|
|
26
|
+
* Hosts sharing one pool have at most one connection per path: two connections to one
|
|
27
|
+
* file on the same thread can wait on each other inside SQLite's synchronous
|
|
28
|
+
* busy handler. A composition root that boots several runtimes in one process
|
|
29
|
+
* creates the pool explicitly (`createConnectionPool`) and hands it to every
|
|
30
|
+
* runtime it boots (`shareConnectionPool`), so those runtimes — including
|
|
31
|
+
* reload-generation forks, which inherit the registration — share the one
|
|
32
|
+
* connection per path. A process that boots a single runtime uses the
|
|
33
|
+
* runtime-owned default the LocalDB plugin registers instead. Each call
|
|
34
|
+
* reports on the runtime it was handed (C083a), never on an ambient default.
|
|
35
|
+
*
|
|
36
|
+
* Maintenance is owned by a runtime lifecycle (RC07). A connection records the
|
|
37
|
+
* runtimes that acquired it and runs its maintenance tick on the lifecycle of
|
|
38
|
+
* one of them that is live and persistent; when that lifecycle ends, the tick
|
|
39
|
+
* ends with it and moves to the next live persistent holder. The reload
|
|
40
|
+
* generation dispatcher reads whichever generation serves: it stays a holder
|
|
41
|
+
* while it serves a live one, so its tick follows it from a retiring
|
|
42
|
+
* generation to the next. A connection no persistent runtime
|
|
43
|
+
* holds gets no tick: it checkpoints on release to zero references and on
|
|
44
|
+
* close/shutdown instead, until a persistent runtime acquires it again.
|
|
13
45
|
*/
|
|
14
|
-
import {
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
consumer: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ConnectionStats {
|
|
23
|
-
total: number;
|
|
24
|
-
active: number;
|
|
25
|
-
idle: number;
|
|
26
|
-
connections: Array<{
|
|
27
|
-
path: string;
|
|
28
|
-
refCount: number;
|
|
29
|
-
ageMs: number;
|
|
30
|
-
consumer: string;
|
|
31
|
-
}>;
|
|
32
|
-
}
|
|
33
|
-
declare class SQLiteConnectionPool {
|
|
46
|
+
import { type RuntimeRef } from '@vibesdotdev/kernel';
|
|
47
|
+
export { PoolDescriptorSchema, type PoolDescriptor } from '../schemas/pool.ts';
|
|
48
|
+
import type { ConnectionStats } from '../schemas/api.ts';
|
|
49
|
+
import type { SqliteConnection } from '../driver/sqlite-driver.ts';
|
|
50
|
+
export type { ConnectionStats, PooledConnection, WalCheckpointTrigger } from '../schemas/api.ts';
|
|
51
|
+
export declare class SQLiteConnectionPool {
|
|
34
52
|
private connections;
|
|
35
|
-
|
|
53
|
+
/** Physical path custody spans every runtime-local manager using this pool. */
|
|
54
|
+
private readonly databasePathLocks;
|
|
36
55
|
private readonly STALE_THRESHOLD_MS;
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
/** Opens in flight, by path: concurrent first acquisitions share one connection. */
|
|
57
|
+
private readonly opening;
|
|
58
|
+
/** Serialize managed initialization, migration, release and reset against the same physical file. */
|
|
59
|
+
withDatabasePathLock<T>(dbPath: string, task: () => Promise<T>): Promise<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Get or create a database connection with optimal configuration, opened
|
|
62
|
+
* through the SQLite driver the calling runtime's host registered. The
|
|
63
|
+
* calling runtime becomes a holder of the connection and reports the open.
|
|
64
|
+
* A runtime whose disposal began is refused before any connection opens
|
|
65
|
+
* (`CANCELLED` `runtime-disposed`), and again if it began while the open
|
|
66
|
+
* was in flight. Cancellation before publication closes the startup handle.
|
|
67
|
+
*/
|
|
68
|
+
getConnection(runtime: RuntimeRef, dbPath: string, consumer?: string): Promise<SqliteConnection>;
|
|
69
|
+
/** Open and pool the connection at `dbPath` with the LocalDB pragmas, through the runtime's driver. */
|
|
70
|
+
private open;
|
|
71
|
+
/**
|
|
72
|
+
* Record `runtime` as a holder of the pooled connection at `dbPath`, so its
|
|
73
|
+
* maintenance can run on (or move to) that runtime. No connection there:
|
|
74
|
+
* nothing to hold.
|
|
75
|
+
*/
|
|
76
|
+
retain(runtime: RuntimeRef, dbPath: string): void;
|
|
77
|
+
private hold;
|
|
39
78
|
/**
|
|
40
|
-
*
|
|
79
|
+
* Keep the connection's tick on a live persistent holder. A tick whose
|
|
80
|
+
* lifecycle (the one it started on) is still live, on a runtime that still
|
|
81
|
+
* holds the connection, stays where it is;
|
|
82
|
+
* otherwise the first live persistent holder takes it, and holders that
|
|
83
|
+
* ended are dropped.
|
|
41
84
|
*/
|
|
42
|
-
|
|
85
|
+
private ensureMaintenance;
|
|
43
86
|
/**
|
|
44
|
-
*
|
|
87
|
+
* Run the connection's tick on the lifecycle `runtime` reads now. The tick
|
|
88
|
+
* ends when that lifecycle ends (it clears every interval). At that moment
|
|
89
|
+
* the runtime is dropped as a holder unless it now reads a live lifecycle
|
|
90
|
+
* (the reload generation dispatcher, whose `lifecycle` follows whichever
|
|
91
|
+
* generation serves), and the tick moves to the next live persistent
|
|
92
|
+
* holder, that runtime included.
|
|
45
93
|
*/
|
|
46
|
-
private
|
|
94
|
+
private maintainOn;
|
|
95
|
+
/** One maintenance tick for one connection. It never throws into the timer: a failure is logged with its cause. */
|
|
96
|
+
private tick;
|
|
47
97
|
/**
|
|
48
98
|
* Release a connection (decrement reference count)
|
|
49
99
|
* Connection remains in pool for reuse
|
|
50
100
|
*/
|
|
51
|
-
releaseConnection(dbPath: string): void;
|
|
101
|
+
releaseConnection(runtime: RuntimeRef, dbPath: string): void;
|
|
52
102
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
103
|
+
* Run one observed, non-blocking checkpoint attempt and record its outcome,
|
|
104
|
+
* reported on `runtime`. A busy attempt is logged at warn (a run of
|
|
105
|
+
* {@link WAL_BUSY_STARVATION_THRESHOLD} at error, as starvation), switches
|
|
106
|
+
* the next attempt's mode, and backs the connection off by whole windows. A
|
|
107
|
+
* checkpoint SQLite itself rejects is logged at error with its cause and
|
|
108
|
+
* never blocks the caller's close or tick.
|
|
55
109
|
*/
|
|
56
|
-
|
|
110
|
+
private observeCheckpoint;
|
|
57
111
|
/**
|
|
58
|
-
*
|
|
112
|
+
* Bound how long a pooled connection may sit inside a transaction. SQLite
|
|
113
|
+
* is synchronous, so a transaction a tick can observe spans an `await`; one
|
|
114
|
+
* older than {@link MAX_TRANSACTION_AGE_MS} pins every WAL frame written
|
|
115
|
+
* after it began, in every process. It is rolled back and reported; the
|
|
116
|
+
* owner's later COMMIT then fails loudly rather than the WAL growing silently.
|
|
117
|
+
*
|
|
118
|
+
* @returns whether the connection is still inside a transaction.
|
|
59
119
|
*/
|
|
60
|
-
private
|
|
120
|
+
private enforceTransactionBound;
|
|
61
121
|
/**
|
|
62
|
-
*
|
|
122
|
+
* Report the statements this window recorded as slow, on `runtime` and once
|
|
123
|
+
* per connection. Each report carries the connection's consumer and database
|
|
124
|
+
* with the statement's operation and table; a window that recorded more than
|
|
125
|
+
* it kept says so rather than reading as a complete count.
|
|
63
126
|
*/
|
|
64
|
-
private
|
|
127
|
+
private reportSlowStatements;
|
|
65
128
|
/**
|
|
66
|
-
*
|
|
129
|
+
* One idle window for one connection: report what it recorded as slow, bound
|
|
130
|
+
* an open transaction, close the connection when it has been unused for 30+
|
|
131
|
+
* minutes with zero references, or make at most one observed checkpoint
|
|
132
|
+
* attempt when it is not inside a transaction and not backing off. Every step
|
|
133
|
+
* reports its own failure.
|
|
67
134
|
*/
|
|
68
|
-
private
|
|
135
|
+
private maintainConnection;
|
|
69
136
|
/**
|
|
70
|
-
*
|
|
137
|
+
* One maintenance pass over every pooled connection, reported on `runtime`.
|
|
138
|
+
* Each connection's lifecycle tick runs the same window for that connection
|
|
139
|
+
* alone; hosts and tests may call this directly.
|
|
71
140
|
*/
|
|
72
|
-
|
|
141
|
+
maintain(runtime: RuntimeRef, now?: number): void;
|
|
73
142
|
/**
|
|
74
|
-
*
|
|
143
|
+
* Close one pooled connection and remove it from the pool, reported on
|
|
144
|
+
* `runtime`. A connection still inside a transaction is closed without a
|
|
145
|
+
* checkpoint, and SQLite discards that transaction: the discard is
|
|
146
|
+
* reported, never silent. A close SQLite refuses throws
|
|
147
|
+
* `localdb-close-failed` (the original error as `cause`) and the connection
|
|
148
|
+
* stays pooled, still maintained, for a retry.
|
|
75
149
|
*/
|
|
76
|
-
|
|
150
|
+
private closePooled;
|
|
77
151
|
/**
|
|
78
|
-
*
|
|
152
|
+
* Refuse destructive replacement while another lifecycle or pooled reference
|
|
153
|
+
* holds the file. Only the requesting instance's actual open connection may
|
|
154
|
+
* account for one reference; legacy/raw borrowers keep their custody too.
|
|
155
|
+
* Call under the database path lock, before releasing or closing anything.
|
|
79
156
|
*/
|
|
80
|
-
|
|
157
|
+
assertCanReplaceDatabase(runtime: RuntimeRef, dbPath: string, ownedConnection?: SqliteConnection): void;
|
|
158
|
+
/**
|
|
159
|
+
* Give back one pooled reference no live runtime holds: every recorded
|
|
160
|
+
* holder ended (or none is recorded) while the reference count is still
|
|
161
|
+
* nonzero — typically a client of a runtime that ended without releasing.
|
|
162
|
+
* Returns whether a reference was given back. A connection another live
|
|
163
|
+
* runtime still holds is never touched.
|
|
164
|
+
*/
|
|
165
|
+
releaseOrphanedConnection(dbPath: string): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Close a specific connection immediately. Only closes if the reference
|
|
168
|
+
* count is zero, unless forced. Returns whether it closed; a close SQLite
|
|
169
|
+
* refuses throws `localdb-close-failed` and leaves the connection pooled.
|
|
170
|
+
*/
|
|
171
|
+
closeConnection(runtime: RuntimeRef, dbPath: string, force?: boolean): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Give back every connection `runtime` holds (typically at its disposal),
|
|
174
|
+
* reported on `runtime`; runtimes that ended hold nothing. A connection
|
|
175
|
+
* another live runtime still holds (another root, or the root a disposing
|
|
176
|
+
* reload generation was forked from) stays pooled for it, its maintenance moving to that
|
|
177
|
+
* holder; every other connection closes. Every close is attempted; the ones
|
|
178
|
+
* SQLite refuses stay pooled and are reported together in one AggregateError
|
|
179
|
+
* so the runtime owner can report them and retry.
|
|
180
|
+
*/
|
|
181
|
+
closeAll(runtime: RuntimeRef, retainedPaths?: ReadonlySet<string>): void;
|
|
182
|
+
/** Whether a managed handle still names the pooled connection at this path. */
|
|
183
|
+
ownsConnection(dbPath: string, db: SqliteConnection): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Get pool statistics
|
|
186
|
+
*/
|
|
187
|
+
getStats(): ConnectionStats;
|
|
81
188
|
}
|
|
82
|
-
|
|
83
|
-
|
|
189
|
+
/**
|
|
190
|
+
* The `localdb/pool` kind: the process's physical SQLite connections, owned
|
|
191
|
+
* through the kernel. The pool holds live host handles, so — unlike migration
|
|
192
|
+
* declarations, which each runtime owns separately — runtimes that must open
|
|
193
|
+
* the same file share one pool instance resolved from the runtime they are
|
|
194
|
+
* handed. No module-level pool instance exists: every instance is created
|
|
195
|
+
* explicitly (`createConnectionPool`, the plugin default, or a shared owner a
|
|
196
|
+
* composition root registers) and resolved through the kernel below.
|
|
197
|
+
*/
|
|
198
|
+
export declare const LOCALDB_POOL_KIND = "localdb/pool";
|
|
199
|
+
/** The runtime-owned default pool, created per root runtime by the LocalDB plugin. */
|
|
200
|
+
export declare const DEFAULT_POOL_ID = "pool";
|
|
201
|
+
/**
|
|
202
|
+
* An explicitly shared pool, handed to each runtime by the composition root
|
|
203
|
+
* that boots them. Preferred over the default whenever it is registered.
|
|
204
|
+
*/
|
|
205
|
+
export declare const SHARED_POOL_ID = "shared";
|
|
206
|
+
/** The kind LocalDB registers; an implementation that is not a pool is refused `implementation-invalid`. */
|
|
207
|
+
export declare const poolKind: import("@vibesdotdev/kernel").RuntimeKindDescriptorRecord<SQLiteConnectionPool>;
|
|
208
|
+
/**
|
|
209
|
+
* Create the physical connection pool a composition root hands to the runtimes
|
|
210
|
+
* it boots. One pool per process per database set: every runtime handed the
|
|
211
|
+
* same pool shares the one connection per path.
|
|
212
|
+
*/
|
|
213
|
+
export declare function createConnectionPool(): SQLiteConnectionPool;
|
|
214
|
+
/**
|
|
215
|
+
* Resolve the runtime's physical connection pool through the kernel on every
|
|
216
|
+
* call, so current selection, invalidation, and implementation caching remain
|
|
217
|
+
* owned by the runtime: an explicitly shared pool when the composition root
|
|
218
|
+
* registered one, else the runtime-owned default the LocalDB plugin
|
|
219
|
+
* registered. Anything else (a refused loader, an invalid implementation)
|
|
220
|
+
* propagates unwrapped.
|
|
221
|
+
*/
|
|
222
|
+
export declare function poolOf(runtime: RuntimeRef): Promise<SQLiteConnectionPool>;
|
|
223
|
+
/**
|
|
224
|
+
* The already-resolved pool, or `undefined` when no resolution warmed the
|
|
225
|
+
* kernel cache yet. Synchronous cover for call sites that hold no async
|
|
226
|
+
* context after an async call resolved the pool first.
|
|
227
|
+
*/
|
|
228
|
+
export declare function tryPoolOf(runtime: RuntimeRef): SQLiteConnectionPool | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Register the runtime-owned default pool, unless one is already registered:
|
|
231
|
+
* reload-generation forks inherit their root's registrations, so they keep
|
|
232
|
+
* sharing the root's pool instead of minting a second connection per path.
|
|
233
|
+
*/
|
|
234
|
+
export declare function ensureDefaultPool(runtime: RuntimeRef): void;
|
|
235
|
+
/**
|
|
236
|
+
* Hand one explicitly created pool to a runtime: every runtime the
|
|
237
|
+
* composition root boots against the same database files shares the one
|
|
238
|
+
* connection per path. Fork generations inherit the registration, so they
|
|
239
|
+
* share it too.
|
|
240
|
+
*/
|
|
241
|
+
export declare function shareConnectionPool(runtime: RuntimeRef, pool: SQLiteConnectionPool): void;
|
|
84
242
|
//# sourceMappingURL=connection-pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-pool.d.ts","sourceRoot":"","sources":["../../src/core/connection-pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"connection-pool.d.ts","sourceRoot":"","sources":["../../src/core/connection-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAIN,KAAK,UAAU,EACf,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