Ir al contenido
Español

LazyStore

Esta página aún no está disponible en tu idioma.

Defined in: src/persistence/LazyStore.ts:39

Lifecycle shared by every store that talks to an external system: lazy first-use connection, one-shot schema preparation, and ownership-aware teardown.

Construction stays synchronous and side-effect-free — new PostgresJournal(…) must not connect — so the resource opens on the first operation and the in-flight promise is memoized to keep concurrent first calls to a single init. Getting that memoization subtly wrong (racing DDL, two pools where one was intended) is the kind of bug that only shows up under load, which is why it lives in one place.

TResource is whatever the backend family talks to: a SqlPool for the relational stores, a database handle plus its client for MongoDB. The base deliberately knows nothing about it beyond how to prepare and release it.

TResource

close(): Promise<void>

Defined in: src/persistence/LazyStore.ts:66

Promise<void>