mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 16:49:51 -07:00
refactor(sync): extract stats-sync engine behind a DB-driver interface
Move snapshot/merge/quiescence engine and ssh helpers from launcher/sync into src/core/services/stats-sync, parameterized on a minimal SyncDb driver. The launcher binds it to bun:sqlite via launcher/sync/bun-driver; the sync command becomes a thin adapter over the shared sync flow.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Database } from 'bun:sqlite';
|
||||
import type {
|
||||
OpenSyncDb,
|
||||
SyncDb,
|
||||
SyncDbStatement,
|
||||
} from '../../src/core/services/stats-sync/driver.js';
|
||||
|
||||
// bun:sqlite's Database.query() already caches prepared statements per SQL
|
||||
// string, which is exactly what the SyncDb contract asks for.
|
||||
export const openBunSyncDb: OpenSyncDb = (dbPath, options): SyncDb => {
|
||||
const db = new Database(dbPath, options);
|
||||
return {
|
||||
query(sql: string): SyncDbStatement {
|
||||
return db.query(sql);
|
||||
},
|
||||
exec(sql: string): void {
|
||||
db.run(sql);
|
||||
},
|
||||
close(): void {
|
||||
db.close();
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user