import { PureContainer } from '@worktif/utils';
import type { ContainerInitializationState } from '../di/container-lifecycle-manager';
/**
 * Container persistence state information.
 */
export interface ContainerPersistenceState {
    /** Whether the container is persisted across invocations */
    isPersisted: boolean;
    /** Timestamp when container was first initialized */
    initializedAt: number;
    /** Timestamp of last access */
    lastAccessedAt: number;
    /** Number of times container has been accessed */
    accessCount: number;
    /** Container reference validation token */
    validationToken: string;
    /** Service instance cache for performance optimization */
    serviceInstanceCache: Map<string, any>;
    /** Hash computation cache for performance */
    hashComputationCache: Map<string, string>;
    /** Container state snapshot for validation */
    stateSnapshot: {
        serviceCount: number;
        registeredServices: string[];
        containerPhase: string;
    };
}
/**
 * Performance metrics for container operations.
 */
export interface ContainerPerformanceMetrics {
    /** Container initialization time in milliseconds */
    initializationTime: number;
    /** Average service resolution time in milliseconds */
    averageResolutionTime: number;
    /** Cache hit ratio for service resolution */
    cacheHitRatio: number;
    /** Total number of service resolutions */
    totalResolutions: number;
    /** Memory usage estimation */
    estimatedMemoryUsage: number;
    /** Performance degradation over time */
    performanceDegradation: number;
}
/**
 * Service cleanup interface for graceful shutdown.
 */
export interface ServiceCleanup {
    /** Cleanup method called during container shutdown */
    cleanup(): Promise<void> | void;
}
/**
 * Container State Persistence Manager
 *
 * Manages DI container state persistence across Lambda invocations to ensure
 * services remain available and configured after cold start initialization.
 * Provides performance optimizations through caching and efficient state management.
 */
export declare class ContainerStatePersistence {
    private persistenceState;
    private performanceMetrics;
    private cleanupHooks;
    private containerReference;
    private resolutionTimes;
    constructor();
    /**
     * Initialize container state persistence.
     *
     * Sets up persistence state tracking and performance monitoring for the
     * container across Lambda invocations.
     *
     * @param container - Container to persist
     * @param initializationState - Container initialization state
     */
    initializePersistence(container: PureContainer<string>, initializationState: ContainerInitializationState): void;
    /**
     * Validate container state persistence across invocations.
     *
     * Ensures the container reference is still valid and the state has not
     * been corrupted between invocations.
     *
     * @param container - Container to validate
     * @returns True if container state is valid and persistent
     */
    validateContainerPersistence(container: PureContainer<string>): boolean;
    /**
     * Get cached service instance for performance optimization.
     *
     * Retrieves a cached service instance if available, otherwise resolves
     * from container and caches the result.
     *
     * @param container - Container to resolve from
     * @param serviceKey - Service key to resolve
     * @returns Cached or resolved service instance
     */
    getCachedServiceInstance(container: PureContainer<string>, serviceKey: string): any;
    /**
     * Get cached hash computation for performance optimization.
     *
     * Retrieves a cached hash value if available, otherwise computes
     * and caches the result.
     *
     * @param classCode - Class code to hash
     * @param hashFunction - Hash computation function
     * @returns Cached or computed hash value
     */
    getCachedHashComputation(classCode: string, hashFunction: (code: string) => string): string;
    /**
     * Register cleanup hook for graceful service shutdown.
     *
     * Allows services to register cleanup functions that will be called
     * when the container is being shut down.
     *
     * @param cleanup - Cleanup hook to register
     */
    registerCleanupHook(cleanup: ServiceCleanup): void;
    /**
     * Unregister cleanup hook.
     *
     * @param cleanup - Cleanup hook to unregister
     */
    unregisterCleanupHook(cleanup: ServiceCleanup): void;
    /**
     * Perform graceful container cleanup.
     *
     * Calls all registered cleanup hooks and clears persistence state.
     * This should be called when the Lambda container is being shut down.
     */
    performCleanup(): Promise<void>;
    /**
     * Get container persistence state.
     *
     * @returns Current persistence state or null if not initialized
     */
    getPersistenceState(): ContainerPersistenceState | null;
    /**
     * Get performance metrics for container operations.
     *
     * @returns Current performance metrics
     */
    getPerformanceMetrics(): ContainerPerformanceMetrics;
    /**
     * Check if container is currently persisted.
     *
     * @returns True if container state is persisted
     */
    isPersisted(): boolean;
    /**
     * Get container access statistics.
     *
     * @returns Access count and timing information
     */
    getAccessStatistics(): {
        accessCount: number;
        initializedAt: number;
        lastAccessedAt: number;
        totalUptime: number;
    };
    /**
     * Clear performance caches to free memory.
     *
     * Clears service instance cache and hash computation cache while
     * maintaining persistence state.
     */
    clearPerformanceCaches(): void;
    /**
     * Generate validation token for container state.
     *
     * @param container - Container to generate token for
     * @returns Validation token string
     */
    private generateValidationToken;
    /**
     * Extract service names from container.
     *
     * @param container - Container to extract services from
     * @returns Array of service names
     */
    private extractServiceNames;
    /**
     * Record service resolution time for performance tracking.
     *
     * @param resolutionTime - Time taken to resolve service
     * @param wasCached - Whether the resolution was from cache
     */
    private recordResolutionTime;
    /**
     * Update performance metrics based on current state.
     */
    private updatePerformanceMetrics;
}
