1 | import type { BetterIntervalID } from '@apify/utilities';
|
2 | import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
3 | import { Configuration } from '../configuration';
|
4 | export declare const enum EventType {
|
5 | PERSIST_STATE = "persistState",
|
6 | SYSTEM_INFO = "systemInfo",
|
7 | MIGRATING = "migrating",
|
8 | ABORTING = "aborting",
|
9 | EXIT = "exit"
|
10 | }
|
11 | export declare type EventTypeName = EventType | 'systemInfo' | 'persistState' | 'migrating' | 'aborting' | 'exit';
|
12 | interface Intervals {
|
13 | persistState?: BetterIntervalID;
|
14 | systemInfo?: BetterIntervalID;
|
15 | }
|
16 | export declare abstract class EventManager {
|
17 | readonly config: Configuration;
|
18 | protected events: AsyncEventEmitter<Record<PropertyKey, unknown[]> & import("@vladfrangu/async_event_emitter").AsyncEventEmitterPredefinedEvents>;
|
19 | protected initialized: boolean;
|
20 | protected intervals: Intervals;
|
21 | protected log: import("@apify/log").Log;
|
22 | constructor(config?: Configuration);
|
23 | /**
|
24 | * Initializes the event manager by creating the `persistState` event interval.
|
25 | * This is automatically called at the beginning of `crawler.run()`.
|
26 | */
|
27 | init(): Promise<void>;
|
28 | /**
|
29 | * Clears the internal `persistState` event interval.
|
30 | * This is automatically called at the end of `crawler.run()`.
|
31 | */
|
32 | close(): Promise<void>;
|
33 | on(event: EventTypeName, listener: (...args: any[]) => any): void;
|
34 | off(event: EventTypeName, listener?: (...args: any[]) => any): void;
|
35 | emit(event: EventTypeName, ...args: unknown[]): void;
|
36 | isInitialized(): boolean;
|
37 | /**
|
38 | * @internal
|
39 | */
|
40 | listenerCount(event: EventTypeName): number;
|
41 | /**
|
42 | * @internal
|
43 | */
|
44 | listeners(event: EventTypeName): (() => Promise<unknown>)[];
|
45 | /**
|
46 | * @internal
|
47 | */
|
48 | waitForAllListenersToComplete(): Promise<boolean>;
|
49 | }
|
50 | export {};
|
51 |
|
\ | No newline at end of file |