PlatformScheduleRunner
in package
Table of Contents
Constants
- SCOPE_ALL_ACTIVE_TENANTS : mixed = 'all_active_tenants'
- SCOPE_PLATFORM : mixed = 'platform'
- SCOPE_SINGLE_TENANT : mixed = 'single_tenant'
- VALID_SCOPES : array<int, string> = [self::SCOPE_PLATFORM, self::SCOPE_ALL_ACTIVE_T...
Properties
- $dispatcher : PlatformScheduleDispatcherInterface|null
- $tenantConnectionManager : TenantConnectionManager|null
Methods
- __construct() : mixed
- Constructor.
- run() : array<string, int|string>
- Run an enabled platform schedule by name.
- runDue() : array{schedules: int, completed: int, failed: int, jobsCreated: int}
- Run schedules that are due, using advisory locks to prevent duplicate dispatch.
- scrubError() : string
- Redact sensitive values from an error before storing it in platform_jobs.
- acquireLock() : bool
- Acquire the PostgreSQL advisory lock for a due schedule.
- activeTenants() : array<int, TenantMetadata>
- dispatchTarget() : int
- failFast() : bool
- Whether a tenant fan-out schedule should stop after the first target failure.
- findSchedule() : array<string, mixed>|null
- getDispatcher() : PlatformScheduleDispatcherInterface
- Resolve the command dispatcher.
- isTruthy() : bool
- Normalize database truthy values across PostgreSQL/SQLite test doubles.
- jobParameters() : array<string, string>
- markScheduleStarted() : void
- normalizeJson() : array<int, mixed>|array<string, mixed>
- normalizeSchedule() : array<string, mixed>
- now() : DateTime
- Return the current timestamp.
- recordEmptyRuns() : bool
- Whether a successful schedule target with no activity should be retained.
- releaseLock() : void
- Release the PostgreSQL advisory lock for a schedule.
- resolveTargets() : array<int, TenantMetadata|null>
- runTarget() : array{status: string, lastError: string|null, jobRecorded: bool}
- singleTenant() : TenantMetadata
Constants
SCOPE_ALL_ACTIVE_TENANTS
public
mixed
SCOPE_ALL_ACTIVE_TENANTS
= 'all_active_tenants'
SCOPE_PLATFORM
public
mixed
SCOPE_PLATFORM
= 'platform'
SCOPE_SINGLE_TENANT
public
mixed
SCOPE_SINGLE_TENANT
= 'single_tenant'
VALID_SCOPES
private
array<int, string>
VALID_SCOPES
= [self::SCOPE_PLATFORM, self::SCOPE_ALL_ACTIVE_TENANTS, self::SCOPE_SINGLE_TENANT]
Properties
$dispatcher read-only
private
PlatformScheduleDispatcherInterface|null
$dispatcher
= null
$tenantConnectionManager read-only
private
TenantConnectionManager|null
$tenantConnectionManager
= null
Methods
__construct()
Constructor.
public
__construct([PlatformScheduleDispatcherInterface|null $dispatcher = null ][, TenantConnectionManager|null $tenantConnectionManager = null ]) : mixed
Parameters
- $dispatcher : PlatformScheduleDispatcherInterface|null = null
-
Optional dispatcher
- $tenantConnectionManager : TenantConnectionManager|null = null
-
Optional tenant connection manager
run()
Run an enabled platform schedule by name.
public
run(string $name) : array<string, int|string>
Parameters
- $name : string
-
Schedule name
Return values
array<string, int|string>runDue()
Run schedules that are due, using advisory locks to prevent duplicate dispatch.
public
runDue([int $limit = 100 ]) : array{schedules: int, completed: int, failed: int, jobsCreated: int}
Parameters
- $limit : int = 100
Return values
array{schedules: int, completed: int, failed: int, jobsCreated: int}scrubError()
Redact sensitive values from an error before storing it in platform_jobs.
public
static scrubError(string $message) : string
Parameters
- $message : string
-
Error message
Return values
stringacquireLock()
Acquire the PostgreSQL advisory lock for a due schedule.
private
acquireLock(string $lockKey) : bool
Parameters
- $lockKey : string
Return values
boolactiveTenants()
private
activeTenants() : array<int, TenantMetadata>
Return values
array<int, TenantMetadata>dispatchTarget()
private
dispatchTarget(array<string, mixed> $schedule, TenantMetadata|null $tenant) : int
Parameters
- $schedule : array<string, mixed>
-
Schedule row
- $tenant : TenantMetadata|null
-
Tenant target
Return values
int —Number of work items processed or dispatched
failFast()
Whether a tenant fan-out schedule should stop after the first target failure.
private
failFast(array<string, mixed> $schedule) : bool
Parameters
- $schedule : array<string, mixed>
-
Schedule row
Return values
boolfindSchedule()
private
findSchedule(string $name) : array<string, mixed>|null
Parameters
- $name : string
Return values
array<string, mixed>|nullgetDispatcher()
Resolve the command dispatcher.
private
getDispatcher() : PlatformScheduleDispatcherInterface
Return values
PlatformScheduleDispatcherInterfaceisTruthy()
Normalize database truthy values across PostgreSQL/SQLite test doubles.
private
isTruthy(mixed $value) : bool
Parameters
- $value : mixed
-
Value to check
Return values
booljobParameters()
private
jobParameters(array<string, mixed> $schedule) : array<string, string>
Parameters
- $schedule : array<string, mixed>
-
Schedule row
Return values
array<string, string>markScheduleStarted()
private
markScheduleStarted(array<string, mixed> $schedule, DateTime $now) : void
Parameters
- $schedule : array<string, mixed>
-
Schedule row
- $now : DateTime
-
Start time
normalizeJson()
private
normalizeJson(mixed $value) : array<int, mixed>|array<string, mixed>
Parameters
- $value : mixed
Return values
array<int, mixed>|array<string, mixed>normalizeSchedule()
private
normalizeSchedule(array<string, mixed> $row) : array<string, mixed>
Parameters
- $row : array<string, mixed>
-
Schedule row
Return values
array<string, mixed>now()
Return the current timestamp.
private
now() : DateTime
Return values
DateTimerecordEmptyRuns()
Whether a successful schedule target with no activity should be retained.
private
recordEmptyRuns(array<string, mixed> $schedule) : bool
Parameters
- $schedule : array<string, mixed>
-
Schedule row
Return values
boolreleaseLock()
Release the PostgreSQL advisory lock for a schedule.
private
releaseLock(string $lockKey) : void
Parameters
- $lockKey : string
resolveTargets()
private
resolveTargets(array<string, mixed> $schedule) : array<int, TenantMetadata|null>
Parameters
- $schedule : array<string, mixed>
-
Schedule row
Return values
array<int, TenantMetadata|null>runTarget()
private
runTarget(array<string, mixed> $schedule, TenantMetadata|null $tenant) : array{status: string, lastError: string|null, jobRecorded: bool}
Parameters
- $schedule : array<string, mixed>
-
Schedule row
- $tenant : TenantMetadata|null
-
Tenant target
Return values
array{status: string, lastError: string|null, jobRecorded: bool}singleTenant()
private
singleTenant(array<string, mixed> $schedule) : TenantMetadata
Parameters
- $schedule : array<string, mixed>
-
Schedule row