import { AsyncService, Class } from "@spinajs/di"; import { Log } from "@spinajs/log-common"; import { LogArchiveStrategy } from "./archive-strategy.js"; import { LogRetentionStrategy } from "./retention-strategy.js"; import { ILogArchiveContext } from "./context.js"; /** * Orchestrates rotation + retention for a single file log target. * * It owns nothing schedule-wise itself: it resolves ONE rotation strategy * ( `archiveStrategy` ) and a LIST of retention strategies * ( `retentionStrategies` ) by class name from DI, delegates start / stop to the * rotation strategy, and provides the shared `rotate()` routine every rotation * ( interval, cron or manual ) funnels through. * * `@NewInstance()` - each file target gets its own service ( per-target * scheduling and strategy state ). */ export declare class LogArchiveService extends AsyncService { protected Logger: Log; protected ArchiveStrategy: LogArchiveStrategy; protected RetentionStrategies: LogRetentionStrategy[]; /** * Resolves the configured rotation + retention strategies by class name. * Follows the fs temp-provider mechanism: look the class up in the DI * registry by name, then resolve an instance. */ resolve(): Promise; /** * Wires strategies for the given context and starts the rotation schedule. */ start(ctx: ILogArchiveContext): Promise; /** * Stops the rotation schedule. Safe to call multiple times. */ stop(): void; /** * Single rotation routine, shared by every scheduling strategy: * * 1. acquire the target write-lock so no append runs while we rename, * 2. rename the active file to a sequenced archive name in the archive dir, * 3. compress ( zip into archiveFs, drop the raw file ) OR move cross-fs, * 4. run every retention strategy in order, * 5. release the lock ( always, even on failure ). * * The whole routine is guarded so a failed rotation neither crashes the * scheduler nor leaves the lock held. */ rotate(ctx: ILogArchiveContext): Promise; /** * Renames the active log file into the archive dir under a unique * `archived__` name. When `archiveFs` differs from `fs` the * file is first renamed within `fs` then moved across. * * Returns the archive path relative to `archiveFs`. */ protected moveToArchive(ctx: ILogArchiveContext): Promise; /** * Zips `archived` into `archiveFs` and removes the raw archived file, so the * archive dir only ever holds the compressed copy. */ protected compress(ctx: ILogArchiveContext, archived: string): Promise; /** * Next archive sequence number for a given base name. Uses existing archive * file names first, falling back to a timestamp so two rotations in the same * tick never collide. */ protected nextSequence(ctx: ILogArchiveContext, name: string, ext: string): Promise; /** * Resolves a strategy instance by class name, mirroring the fs temp-provider * mechanism: look the class up in the DI registry by name, then resolve an * instance ( `@NewInstance()` gives a fresh per-target instance ). */ protected resolveStrategy(base: Class, className: string): T; } //# sourceMappingURL=LogArchiveService.d.ts.map