import type { WorkerOptions } from 'bullmq';
import type { Logger } from 'pino';
import type { ToroTask } from './client.js';
import { EventManager } from './event-manager.js';
import type { TaskJob } from './job.js';
import type { Task } from './task.js';
import type { TaskJobOptions } from './types/index.js';
import { TaskWorkerQueue } from './worker-queue.js';
type PayloadType = any;
type ReturnType = any;
/**
 * Manages the registration and dispatching of events to subscribed Tasks.
 * It uses its own BullMQ queue to process published events.
 * Maintains a local cache (`activeEvents`) of events presumed to have subscribers.
 */
export declare class EventDispatcher extends TaskWorkerQueue<PayloadType, ReturnType> {
    manager: EventManager;
    activeEvents: Set<string>;
    subscribedToActiveEvents: boolean;
    disableSubscription: boolean;
    private setActiveEventsDebounced;
    private setActiveEventsTimeout;
    constructor(taskClient: ToroTask, parentLogger: Logger, name?: string);
    subscribeToActiveEvents(): Promise<void>;
    /**
     * Starts the event manager before the event dispatcher
     */
    startWorker(options?: WorkerOptions): Promise<import("./worker.js").TaskWorker<any, any, string, TaskJob<any, any, string, import("./types/job.js").TaskJobData<any>, import("./types/job.js").TaskJobState>>>;
    /**
     * Fetches the list of event keys from Redis and updates the local activeEvents cache.
     * Note: This scans keys, but doesn't verify HLEN > 0 for each. It assumes
     * the existence of the key implies active subscribers for performance.
     */
    setActiveEvents(): Promise<void>;
    /**
     * Removes all event registrations associated with a specific task.
     * Useful when a task is updated or removed.
     * @param task The Task instance whose registrations should be cleared.
     */
    clearTaskEvents(task: Task<any, any>): Promise<void>;
    /**
     * Removes all task registrations for a specific event name.
     * Also removes the event name from the sets of associated tasks.
     * @param eventName The name of the event to clear.
     */
    clearEvent(eventName: string): Promise<void>;
    /**
     * Sends an event by adding a job to the event queue.
     * The job name will be the event name.
     * @param eventName The name of the event to send.
     * @param data The data payload for the event.
     * @param options Optional BullMQ job options.
     */
    send<E = unknown>(eventName: string, data: E, options?: TaskJobOptions): Promise<TaskJob<PayloadType, any> | undefined>;
    /**
     * Processes jobs from the event queue.
     * Looks up event subscription JSON in Redis Hash using the EventManager
     * and triggers associated tasks by adding jobs to their respective queues.
     * This is intended to be used as the processor function for the BullMQ Worker.
     * @param job The job received from the event queue.
     */
    process(job: TaskJob): Promise<void>;
}
export {};
//# sourceMappingURL=event-dispatcher.d.ts.map