/**
 * Worker Factory
 * Central factory for creating workers with all advanced features
 * Sealed namespace for immutability
 */
import { type IDatabase, type RedisConfig } from '../../../src/index.js';
import { Worker, type Job, type WorkerOptions } from 'bullmq';
import { type AutoScalerConfig } from './AutoScaler';
import { type ComplianceConfig } from './ComplianceManager';
import { type RetentionPolicy } from './DeadLetterQueue';
import { type ObservabilityConfig } from './Observability';
import { type WorkerRecord } from './storage/WorkerStore';
export declare const WorkerCreationStatus: {
    readonly CREATING: "creating";
    readonly CONNECTING: "connecting";
    readonly STARTING: "starting";
    readonly RUNNING: "running";
    readonly FAILED: "failed";
    readonly STOPPED: "stopped";
};
export type WorkerCreationStatus = (typeof WorkerCreationStatus)[keyof typeof WorkerCreationStatus];
export type WorkerFactoryConfig = {
    name: string;
    version?: string;
    queueName: string;
    processor: (job: Job) => Promise<unknown>;
    processorSpec?: string;
    options?: WorkerOptions;
    autoStart?: boolean;
    activeStatus?: boolean;
    infrastructure?: {
        redis?: RedisConfigInput;
        persistence?: WorkerPersistenceConfig;
        deadLetterQueue?: {
            redis?: RedisConfigInput;
            policy: RetentionPolicy;
        };
        compliance?: {
            redis?: RedisConfigInput;
            config?: Partial<ComplianceConfig>;
        };
        observability?: ObservabilityConfigInput;
        autoScaler?: AutoScalerConfig;
    };
    features?: {
        clustering?: boolean;
        metrics?: boolean;
        autoScaling?: boolean;
        circuitBreaker?: boolean;
        deadLetterQueue?: boolean;
        resourceMonitoring?: boolean;
        compliance?: boolean;
        observability?: boolean;
        plugins?: boolean;
        versioning?: boolean;
        datacenterOrchestration?: boolean;
    };
    datacenter?: {
        primaryRegion: string;
        secondaryRegions?: string[];
        affinityRules?: {
            preferLocal?: boolean;
            maxLatency?: number;
            avoidRegions?: string[];
        };
    };
};
export type WorkerInstance = {
    worker: Worker;
    config: WorkerFactoryConfig;
    startedAt: Date;
    status: WorkerCreationStatus;
    lastHealthCheck?: Date;
    connectionState?: 'disconnected' | 'connecting' | 'connected' | 'error';
};
type RedisEnvConfig = {
    env?: true;
    host?: string;
    port?: number;
    password?: string;
    db?: string;
};
type RedisConfigInput = RedisConfig | RedisEnvConfig;
export type WorkerPersistenceConfig = {
    driver: 'memory';
} | {
    driver: 'redis';
    redis?: RedisConfigInput;
    keyPrefix?: string;
} | {
    driver: 'database';
    client?: IDatabase | string;
    connection?: string;
    table?: string;
};
type ObservabilityConfigInput = ObservabilityConfig | {
    enabled?: boolean;
    prometheus?: Partial<ObservabilityConfig['prometheus']>;
    openTelemetry?: Partial<ObservabilityConfig['openTelemetry']>;
    datadog?: Partial<ObservabilityConfig['datadog']>;
};
export type ProcessorResolver = (name: string) => WorkerFactoryConfig['processor'] | undefined | Promise<WorkerFactoryConfig['processor'] | undefined>;
/**
 * Worker Factory - Sealed namespace
 */
export declare const WorkerFactory: Readonly<{
    registerProcessor: (name: string, processor: WorkerFactoryConfig["processor"]) => void;
    registerProcessors: (processors: Record<string, WorkerFactoryConfig["processor"]>) => void;
    registerProcessorPaths: (paths: Record<string, string>) => void;
    registerProcessorResolver: (resolver: ProcessorResolver) => void;
    registerProcessorSpec: (spec: string, processor: WorkerFactoryConfig["processor"]) => void;
    resolveProcessorPath: (modulePath: string) => Promise<WorkerFactoryConfig["processor"] | undefined>;
    resolveProcessorSpec: (spec: string) => Promise<WorkerFactoryConfig["processor"] | undefined>;
    /**
     * Register a new worker configuration without starting it.
     */
    register(config: WorkerFactoryConfig): Promise<void>;
    /**
     * Create new worker with full setup
     */
    create(config: WorkerFactoryConfig): Promise<Worker>;
    /**
     * Get worker instance
     */
    get(name: string): WorkerInstance | null;
    /**
     * Update worker status directly (used by HealthMonitor)
     */
    updateStatus(name: string, status: string, error?: Error | string): Promise<void>;
    /**
     * Stop worker
     */
    stop(name: string, persistenceOverride?: WorkerPersistenceConfig, options?: {
        skipPersistedUpdate?: boolean;
    }): Promise<void>;
    /**
     * Restart worker
     */
    restart(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Pause worker
     */
    pause(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Resume worker
     */
    resume(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Update auto-start for persisted worker
     */
    setAutoStart(name: string, autoStart: boolean, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Update active status for a worker
     */
    setWorkerActiveStatus(name: string, activeStatus: boolean, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Get active status for a worker
     */
    getWorkerActiveStatus(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<boolean | null>;
    /**
     * Update persisted worker record and in-memory config if running.
     */
    update(name: string, patch: Partial<WorkerRecord> | WorkerRecord, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Start worker
     */
    start(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * List all workers
     */
    list(): string[];
    /**
     * List all persisted workers
     */
    listPersisted(persistenceOverride?: WorkerPersistenceConfig, options?: {
        offset?: number;
        limit?: number;
        search?: string;
        includeInactive?: boolean;
    }): Promise<string[]>;
    listPersistedRecords(persistenceOverride?: WorkerPersistenceConfig, options?: {
        offset?: number;
        limit?: number;
        search?: string;
        includeInactive?: boolean;
    }): Promise<WorkerRecord[]>;
    /**
     * Start a worker from persisted storage when it is not registered.
     */
    startFromPersisted(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * List worker definitions discovered from project files.
     */
    listFileBackedRecords(): Promise<WorkerRecord[]>;
    /**
     * Get a file-backed worker definition by name.
     */
    getFileBackedRecord(name: string): Promise<WorkerRecord | null>;
    /**
     * Get persisted worker record
     */
    getPersisted(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<WorkerRecord | null>;
    /**
     * Remove worker
     */
    remove(name: string, persistenceOverride?: WorkerPersistenceConfig): Promise<void>;
    /**
     * Get worker metrics
     */
    getMetrics(name: string): Promise<unknown>;
    /**
     * Get worker health
     */
    getHealth(name: string): Promise<unknown>;
    /**
     * Shutdown all workers
     */
    shutdown(): Promise<void>;
    /**
     * Reset persistence connection state.
     * Useful when connections become stale in long-running processes or serverless environments.
     */
    resetPersistence(): Promise<void>;
}>;
export {};
//# sourceMappingURL=WorkerFactory.d.ts.map