import { DataSource, EntityManager, EntityTarget, Repository } from 'typeorm'; /** * Returns the specified DataSource by name. * @param {string} name - The name of the DataSource. * @returns {DataSource} - The DataSource with the specified name. */ export declare function getDataSource(name?: string): DataSource; /** * Adds a new DataSource with the specified name. * @param {string} name - The name of the DataSource to add. * @param {DataSource} dataSource - The DataSource to add. */ export declare function addDataSource(name: string, dataSource: DataSource): void; /** * Removes a DataSource with the specified name. * @param {string} name - The name of the DataSource to remove. */ export declare function removeDataSource(name: string): void; /** * Returns an array of all registered DataSource names. * @returns {string[]} - An array of DataSource names. */ export declare function getDataSourceNames(): string[]; /** * Returns a repository for the specified entity. * @param {EntityTarget} target - The target entity for which to get the repository. * @returns {Repository} - The repository for the specified entity. */ export declare function getRepository(target: EntityTarget, tx?: EntityManager): Repository; /** * **무거운 읽기를 위한 저장소** — 다른 요청을 붙잡지 않게 별도 연결로 보낸다. * * ── 무엇을 재서 알았나 (2026-08-22) ──────────────────────────────────────── * TypeORM 의 sqlite 드라이버는 연결을 **하나**만 든다(풀 없음). 그래서 무거운 읽기 하나가 도는 동안 * 앱의 **모든** 질의가 그 뒤에 선다 — 수십 행짜리 `users`·`domains` 조회가 30초로 찍혔다. * * 같은 DB(16.3GB · 저널 1,134만 행)에서 실측했다. 무거운 읽기(2만 행)가 도는 동안 가벼운 읽기가 * 얼마나 기다리나: * * DataSource 하나 → 47,647ms * DataSource 둘 → 2,786ms (평균 1,473ms) * * 즉 **sqlite 쪽 분리는 실재한다.** WAL 이면 연결마다 독립으로 읽으므로 잠금·직렬화가 풀린다. * * ── 남는 것을 감추지 않는다 ──────────────────────────────────────────────── * 평균 1,473ms 는 사라지지 않는다. 그것은 sqlite 가 아니라 **행을 객체로 만드는 JS 일**이다 * (같은 측정에서 한 행만 돌려주는 무거운 질의는 가벼운 읽기를 0.3ms 로 두었다). 이벤트 루프는 하나이고, * 그 비용은 DB 를 바꿔도 남는다. 고칠 자리는 연결이 아니라 **그 질의**다 — 페이지 크기·필요한 컬럼만· * 엔티티 대신 raw. 이 함수는 그 일을 대신해 주지 않는다. * * ── 언제 쓰나 ────────────────────────────────────────────────────────────── * **읽기 전용이고, 느린 것이 측정된 경로**에만 쓴다. 두 가지를 주의한다. * * · **쓰지 않는다.** 이 연결로 쓰면 별도 쓰기 주체가 되어 잠금을 다툰다. 쓰기는 `getRepository` 다. * · **쓴 뒤 곧바로 읽는 자리에는 쓰지 않는다.** 쓰기를 `await` 한 뒤라면 WAL 에서 최신 커밋이 보이므로 * 안전하지만, 같은 트랜잭션 안에서 읽어야 하는 값이면 `tx` 를 받는 `getRepository` 를 쓴다. * * 풀이 있는 드라이버(postgres·mysql)에서는 얻을 것이 없으므로 `'read'` 가 `'default'` 를 가리킨다 — * 소비처는 드라이버를 알 필요가 없다. 배포가 그 연결을 원하지 않으면 `ormconfig4Read: false` 로 끈다 * (그때도 이 함수는 그대로 쓸 수 있다 — `'default'` 로 떨어진다). */ export declare function getReadRepository(target: EntityTarget): Repository; /** * Initializes the database connections and data sources. */ export declare const databaseInitializer: () => Promise;