UNPKG

@sailboat-computer/data-storage

Version:

Shared data storage library for sailboat computer v3

108 lines (107 loc) 3.17 kB
/** * Lifecycle manager implementation */ import { LifecycleManager, LifecycleManagerConfig, LifecyclePolicy, StorageManager, DownsamplingEngine, MigrationHandler, DownsamplingHandler } from '../types'; /** * Lifecycle manager implementation */ export declare class LifecycleManagerImpl implements LifecycleManager { private storageManager; private downsamplingEngine?; private config?; private cleanupInterval?; private migrationInterval?; private initialized; private beforeMigrationHandlers; private afterMigrationHandlers; private beforeDownsamplingHandlers; private afterDownsamplingHandlers; /** * Create a new lifecycle manager * * @param storageManager - Storage manager * @param downsamplingEngine - Downsampling engine */ constructor(storageManager: StorageManager, downsamplingEngine?: DownsamplingEngine | undefined); /** * Initialize the lifecycle manager * * @param config - Lifecycle manager configuration */ initialize(config: LifecycleManagerConfig): void; /** * Run cleanup for all policies */ runCleanup(): Promise<void>; /** * Run migration for all policies */ runMigration(): Promise<void>; /** * Run downsampling for a specific rule * * @param ruleId - Downsampling rule ID */ runDownsampling(ruleId: string): Promise<void>; /** * Get all lifecycle policies * * @returns Lifecycle policies */ getPolicies(): LifecyclePolicy[]; /** * Stop the lifecycle manager */ stop(): void; /** * Register a handler to be called before migration * * @param handler - Migration handler */ onBeforeMigration(handler: MigrationHandler): void; /** * Register a handler to be called after migration * * @param handler - Migration handler */ onAfterMigration(handler: MigrationHandler): void; /** * Register a handler to be called before downsampling * * @param handler - Downsampling handler */ onBeforeDownsampling(handler: DownsamplingHandler): void; /** * Register a handler to be called after downsampling * * @param handler - Downsampling handler */ onAfterDownsampling(handler: DownsamplingHandler): void; /** * Run cleanup for a specific policy * * @param policy - Lifecycle policy */ private runCleanupForPolicy; /** * Run migration for a specific policy * * @param policy - Lifecycle policy */ private runMigrationForPolicy; /** * Ensure lifecycle manager is initialized * * @throws StorageError if not initialized */ private ensureInitialized; } /** * Create a new lifecycle manager * * @param storageManager - Storage manager * @param config - Lifecycle manager configuration * @param downsamplingEngine - Downsampling engine (optional) * @returns Lifecycle manager */ export declare function createLifecycleManager(storageManager: StorageManager, config: LifecycleManagerConfig, downsamplingEngine?: DownsamplingEngine): LifecycleManager;