Kfg Documentation
    Preparing search index...

    Interface KfgPoolOptions<D>

    interface KfgPoolOptions<D extends SyncDriver> {
        defaultScope?: string;
        driver: (id: string) => D;
        forceExit?: boolean;
        load?: KfgLoadOptions<D>;
        max?: number;
        onMissingScope?: (operation: string, defaultScope: string) => void;
        resolve?: () => string | null | undefined;
        ttl?: number;
    }

    Type Parameters

    Index
    defaultScope?: string

    Scope used when no scope is active. Off by default: without it, a scope-less operation throws KfgScopeError. Meant as a migration aid — turn it on while call sites are still being moved into scopes.

    driver: (id: string) => D

    Builds the driver for a given scope id (e.g. one file per guild).

    forceExit?: boolean

    Overrides the per-instance forceExit, which the pool forces to false by default. Only set it if a broken scope really should exit the process.

    Load options forwarded to every instance the pool creates.

    max?: number

    Maximum number of instances kept in memory. Beyond it, the least-recently-used ones are evicted. Each instance holds a full config cache, so an unbounded pool grows with the number of scopes ever touched.

    onMissingScope?: (operation: string, defaultScope: string) => void

    Called every time an operation falls back to defaultScope. Lets the host capture its own stack trace on demand; the pool never captures one itself (too expensive per access). Without a hook, the pool warns once and keeps an aggregate count in missingScopeCount.

    resolve?: () => string | null | undefined

    External scope resolver, consulted when no run() is active. Use it when the host already owns the ambient context (its own AsyncLocalStorage, a request store, ...) and should stay the single source of truth. An enclosing run() still wins, since it is explicit at the call site.

    ttl?: number

    Milliseconds of idleness after which an instance is evicted.