Skip to main content

Interface: OperationalHooksConfig<T>

Defined in: electron/utils/operationalHooks.ts:203

Configuration for operational hooks.

Type Parameters​

T​

T = unknown

Properties​

backoff?​

optional backoff?: "exponential" | "linear";

Defined in: electron/utils/operationalHooks.ts:209

Backoff strategy for retry delays.

Default Value​

"exponential";

context?​

optional context?: OperationalHookContextInput;

Defined in: electron/utils/operationalHooks.ts:214

Context data to include in events.


emitEvents?​

optional emitEvents?: boolean;

Defined in: electron/utils/operationalHooks.ts:221

Whether to emit events for this operation.

Default Value​

true;

eventEmitter?​

optional eventEmitter?: TypedEventBus<UptimeEvents>;

Defined in: electron/utils/operationalHooks.ts:226

Event emitter for operation events.


failureLogLevel?​

optional failureLogLevel?:
| OperationalLogLevel
| ((error: Error, attempt: number, maxRetries: number) => OperationalLogLevel);

Defined in: electron/utils/operationalHooks.ts:238

Customize the log level used when the operation fails permanently.

Remarks​

Accepts either a static level or a callback that derives the level from the caught error context. Invalid values fall back to the default setting.

Default Value​

"error";

initialDelay?​

optional initialDelay?: number;

Defined in: electron/utils/operationalHooks.ts:251

Initial delay between retries in milliseconds.

Default Value​

100;

maxRetries?​

optional maxRetries?: number;

Defined in: electron/utils/operationalHooks.ts:258

Maximum number of retry attempts.

Default Value​

3;

onFailure?​

optional onFailure?: (error: Error, attempts: number) => Promisable<void>;

Defined in: electron/utils/operationalHooks.ts:263

Callback when operation fails permanently.

Parameters​

error​

Error

attempts​

number

Returns​

Promisable<void>


onRetry?​

optional onRetry?: (attempt: number, error: Error) => Promisable<void>;

Defined in: electron/utils/operationalHooks.ts:268

Callback when retry is attempted.

Parameters​

attempt​

number

error​

Error

Returns​

Promisable<void>


onSuccess?​

optional onSuccess?: (result: T) => Promisable<void>;

Defined in: electron/utils/operationalHooks.ts:273

Callback when operation succeeds.

Parameters​

result​

T

Returns​

Promisable<void>


operationName​

operationName: string;

Defined in: electron/utils/operationalHooks.ts:278

Name of the operation for logging and event emission.


signal?​

optional signal?: AbortSignal;

Defined in: electron/utils/operationalHooks.ts:288

Optional cancellation signal.

Remarks​

When provided, retries and retry delays will stop as soon as the signal aborts. This is primarily used by monitoring to prevent wasted work after a monitor is stopped/cancelled.


throwOnFailure?​

optional throwOnFailure?: boolean;

Defined in: electron/utils/operationalHooks.ts:295

Whether to throw on final failure.

Default Value​

true;