Skip to main content

QExecutor

@quik/scheduler


@quik/scheduler / QExecutor

Class: QExecutor

Defined in: scheduler/src/QExecutor.ts:52

Default in-memory task scheduler executor.

Extends

  • QObject

Implements

Constructors

Constructor

new QExecutor(): QExecutor

Defined in: scheduler/src/QExecutor.ts:54

Create a new executor instance.

Returns

QExecutor

Overrides

QObject.constructor

Properties

_lastRunStart

protected _lastRunStart: Map<string, DateTime<boolean>>

Defined in: scheduler/src/QExecutor.ts:63


_runningTasks

protected _runningTasks: Map<string, number>

Defined in: scheduler/src/QExecutor.ts:62


_scheduledJobs

protected _scheduledJobs: Map<string, ScheduledTask>

Defined in: scheduler/src/QExecutor.ts:64


_tasks

protected _tasks: QTask[] = []

Defined in: scheduler/src/QExecutor.ts:61

Internal list of task instances registered with the executor.

Accessors

logger

Get Signature

get protected logger(): IQLogger

Defined in: core/src/QObject.ts:15

The logger getter for the object.

Returns

IQLogger

Inherited from

QObject.logger


name

Get Signature

get name(): string

Defined in: core/src/QObject.ts:8

Returns

string

Inherited from

QObject.name


tasks

Get Signature

get tasks(): QTask[]

Defined in: scheduler/src/QExecutor.ts:69

Retrieve registered task instances.

Returns

QTask[]

Array of registered tasks managed by this executor. Contains all scheduled tasks regardless of their state.

Implementation of

IQScheduleExecutor.tasks

Methods

afterExecute()

protected afterExecute(taskExecution, isSuccessfulRun, err?): Promise<void>

Defined in: scheduler/src/QExecutor.ts:220

Hook executed after a task run.

Parameters

taskExecution

QTaskExecution

Execution context for the task.

isSuccessfulRun

boolean

Indicates if the task was executed without error.

err?

QError

Optional error thrown during execution.

Returns

Promise<void>


beforeExecute()

protected beforeExecute(taskExecution): Promise<void>

Defined in: scheduler/src/QExecutor.ts:229

Hook executed before a task run.

Parameters

taskExecution

QTaskExecution

Execution context for the task.

Returns

Promise<void>


cleanup()

cleanup(): void

Defined in: scheduler/src/QExecutor.ts:73

Cleanup the executors.

Returns

void

Implementation of

IQScheduleExecutor.cleanup


endSpan()

protected endSpan(span): void

Defined in: core/src/QObject.ts:35

End a span returned by startSpan.

Parameters

span

TelemetrySpan

The span to end.

Returns

void

Inherited from

QObject.endSpan


execute()

protected execute(task): Promise<void>

Defined in: scheduler/src/QExecutor.ts:147

Execute a single task instance.

Parameters

task

QTask

Task instance to run.

Returns

Promise<void>


getDays()

protected getDays(days, months?): string

Defined in: scheduler/src/QExecutor.ts:313

Convert day values to a cron expression segment.

Parameters

days

ExecutionPlanPeriodDefinition

Day values.

months?

ExecutionPlanPeriodDefinition

Optional months context used for validation.

Returns

string


getExecutionPlan()

protected getExecutionPlan(executionPlan): string

Defined in: scheduler/src/QExecutor.ts:238

Build a cron expression from an execution plan definition.

Parameters

executionPlan

string | IQExecutionPlan

Execution plan object or cron string.

Returns

string


getHours()

protected getHours(hours): string

Defined in: scheduler/src/QExecutor.ts:354

Convert hour values to a cron expression segment.

Parameters

hours

ExecutionPlanPeriodDefinition

Hour values.

Returns

string


getMaxConcurrency()

protected getMaxConcurrency(): number

Defined in: scheduler/src/QExecutor.ts:208

Maximum number of concurrent task executions allowed.

Returns

number


getMinutes()

protected getMinutes(minutes): string

Defined in: scheduler/src/QExecutor.ts:374

Convert minute values to a cron expression segment.

Parameters

minutes

ExecutionPlanPeriodDefinition

Minute values.

Returns

string


getMonths()

protected getMonths(months): string

Defined in: scheduler/src/QExecutor.ts:292

Convert month values to a cron expression segment.

Parameters

months

ExecutionPlanPeriodDefinition

Month values.

Returns

string


getWeekDay()

protected getWeekDay(weekDays): string

Defined in: scheduler/src/QExecutor.ts:394

Convert weekday values to a cron expression segment.

Parameters

weekDays

ExecutionPlanPeriodDefinition

Weekday values.

Returns

string


pause()

pause(taskName): void

Defined in: scheduler/src/QExecutor.ts:117

Pause a single scheduled task without stopping the rest of the scheduler. A paused task can be resumed with resume.

Parameters

taskName

string

Name of the task to pause.

Returns

void


recordSpanError()

protected recordSpanError(span, err): void

Defined in: core/src/QObject.ts:45

Record an exception on an active span.

Parameters

span

TelemetrySpan

The span to record the error on.

err

unknown

The error to record.

Returns

void

Inherited from

QObject.recordSpanError


register()

register(...tasks): void

Defined in: scheduler/src/QExecutor.ts:83

Register one or more tasks to be executed.

Parameters

tasks

...Constructor<QTask>[]

Task constructors to register.

Returns

void

Implementation of

IQScheduleExecutor.register


resume()

resume(taskName): void

Defined in: scheduler/src/QExecutor.ts:132

Resume a previously paused task.

Parameters

taskName

string

Name of the task to resume.

Returns

void


setSpanAttribute()

protected setSpanAttribute(span, key, value): void

Defined in: core/src/QObject.ts:64

Set a single attribute on an active span.

Parameters

span

TelemetrySpan

The span to update.

key

string

Attribute key.

value

string | number | boolean

Attribute value.

Returns

void

Inherited from

QObject.setSpanAttribute


start()

start(): Promise<void>

Defined in: scheduler/src/QExecutor.ts:88

Start the scheduler.

Returns

Promise<void>

Implementation of

IQScheduleExecutor.start


startSpan()

protected startSpan(spanName, options?): TelemetrySpan

Defined in: core/src/QObject.ts:26

Start a telemetry span for the given operation name. Returns undefined when no telemetry provider is active.

Parameters

spanName

string

Name of the span.

options?

TelemetrySpanOptions

Optional span attributes and kind.

Returns

TelemetrySpan

Inherited from

QObject.startSpan


stop()

stop(): Promise<void>

Defined in: scheduler/src/QExecutor.ts:103

Stop all scheduled tasks.

Returns

Promise<void>

Implementation of

IQScheduleExecutor.stop


toSet()

protected toSet(item): Set<number> | "*"

Defined in: scheduler/src/QExecutor.ts:267

Normalise an execution plan field to a Set.

Parameters

item

ExecutionPlanPeriodDefinition

Numeric value, array, set or *.

Returns

Set<number> | "*"

A set, *, or undefined when no value is provided.


transfer()

transfer(originalExecutor): void

Defined in: scheduler/src/QExecutor.ts:78

Transfer state from another executor instance.

Parameters

originalExecutor

QExecutor

Executor to copy tasks from.

Returns

void

Implementation of

IQScheduleExecutor.transfer