Skip to main content

TaskScheduleDefinition.scope

Home > @backstage/backend-tasks > TaskScheduleDefinition > scope

Sets the scope of concurrency control / locking to apply for invocations of this task.

Signature:

scope?: 'global' | 'local';

Remarks

When the scope is set to the default value 'global', the scheduler will attempt to ensure that only one worker machine runs the task at a time, according to the given cadence. This means that as the number of worker hosts increases, the invocation frequency of this task will not go up. Instead, the load is spread randomly across hosts. This setting is useful for tasks that access shared resources, for example catalog ingestion tasks where you do not want many machines to repeatedly import the same data and trample over each other.

When the scope is set to 'local', there is no concurrency control across hosts. Each host runs the task according to the given cadence similarly to setInterval, but the runtime ensures that there are no overlapping runs.