sql-switch - v1.0.1
    Preparing search index...

    Interface CollectorConfig

    Controls write collector behaviour. The collector batches writes in RAM and flushes to the DB in bulk at each interval.

    interface CollectorConfig {
        enabled?: boolean;
        time?: number;
        autoRecover?: boolean;
        recoverAfter?: number;
        flushOnExit?: boolean;
        hooks?: CollectorHooks;
    }
    Index
    enabled?: boolean

    Enable or disable write batching.

    true
    
    time?: number

    Flush interval in milliseconds.

    3000
    

    Values >= 10000 emit a runtime warning — high intervals hurt app responsiveness.

    autoRecover?: boolean

    Let the circuit breaker re-arm itself on a timer after an outage: once recoverAfter is up, one trial flush decides whether the database is back.

    Set false to switch off that timed self-heal => the breaker then stays tripped until the process restarts (the pre-recovery behaviour), only worth it if you'd rather a supervisor replace the process than have it heal in place. Note this disables the automatic, interval driven recovery path only: a flush that succeeds for any other reason still closes the breaker, so the drain on close() or on shutdown can clear it as a side effect of getting your last writes out.

    true

    recoverAfter?: number

    How long to stay in read-only mode before attempting a trial flush, in milliseconds.

    10000

    Ignored when autoRecover is false. Every failed trial re-arms the same wait, so this is also the retry spacing during a long outage => low values hammer a struggling database, high values keep the app read-only longer than it has to be.

    flushOnExit?: boolean

    Drain the buffer when the process is going away => SIGINT, SIGTERM & beforeExit.

    Containers stop processes with SIGTERM, so without this a deploy or a scale down silently loses up to one flush interval of writes. The handler flushes, takes itself off & re-raises the signal, so the app's own shutdown still runs => the library never calls process.exit() for you. Hard kills (SIGKILL) can't be caught by anyone, that window stays lost.

    Set false if your app owns shutdown & already calls await db.close() (which flushes too), or if you don't want a library holding signal listeners at all.

    true

    Observability callbacks. See CollectorHooks.