RestoreStatusService
in package
Tracks restore lock and restore progress in shared cache.
Table of Contents
Constants
- CACHE_CONFIG : mixed = 'restore_status'
- DEFAULT_LOCK_TTL_SECONDS : mixed = 1800
- LOCK_KEY : mixed = 'restore.lock'
- MAX_LOG_ENTRIES : mixed = 500
- STALE_PROGRESS_SECONDS : mixed = 900
- STATUS_KEY : mixed = 'restore.status'
Methods
- acquireLock() : bool
- Acquire restore lock and initialize running status.
- appendLog() : void
- Append a user-visible restore log line to the shared status payload.
- getStatus() : array<string, mixed>
- Return current restore status payload.
- isLocked() : bool
- Check if locked.
- markCompleted() : void
- Mark restore status as completed and clear lock.
- markFailed() : void
- Mark restore status as failed and clear lock.
- releaseLock() : void
- Release the restore lock without changing status payload.
- updateStatus() : void
- Mark status as running and update current phase message.
- clearExpiredLock() : void
- Clear expired lock.
- defaultStatus() : array<string, mixed>
- isExpired() : bool
- Check if expired.
- isoAfterSeconds() : string
- Iso after seconds.
- isOlderThanSeconds() : bool
- Check if older than seconds.
- lockKey() : string
- Tenant-scoped restore lock cache key.
- nowIso() : string
- Now iso.
- readActiveLock() : array<string, mixed>|null
- readStatus() : array<string, mixed>
- statusKey() : string
- Tenant-scoped restore status cache key.
- writeStatus() : void
Constants
CACHE_CONFIG
private
mixed
CACHE_CONFIG
= 'restore_status'
DEFAULT_LOCK_TTL_SECONDS
private
mixed
DEFAULT_LOCK_TTL_SECONDS
= 1800
LOCK_KEY
private
mixed
LOCK_KEY
= 'restore.lock'
MAX_LOG_ENTRIES
private
mixed
MAX_LOG_ENTRIES
= 500
STALE_PROGRESS_SECONDS
private
mixed
STALE_PROGRESS_SECONDS
= 900
STATUS_KEY
private
mixed
STATUS_KEY
= 'restore.status'
Methods
acquireLock()
Acquire restore lock and initialize running status.
public
acquireLock([array<string, mixed> $context = [] ][, int|null $ttlSeconds = null ]) : bool
Parameters
- $context : array<string, mixed> = []
- $ttlSeconds : int|null = null
Return values
boolappendLog()
Append a user-visible restore log line to the shared status payload.
public
appendLog(string $message) : void
Parameters
- $message : string
getStatus()
Return current restore status payload.
public
getStatus() : array<string, mixed>
Return values
array<string, mixed>isLocked()
Check if locked.
public
isLocked() : bool
Return values
boolmarkCompleted()
Mark restore status as completed and clear lock.
public
markCompleted(string $message[, array<string, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string, mixed> = []
markFailed()
Mark restore status as failed and clear lock.
public
markFailed(string $message[, array<string, mixed> $context = [] ]) : void
Set maintenance_required when the database may have been partially reset and normal controllers should not run against the current schema.
Parameters
- $message : string
- $context : array<string, mixed> = []
releaseLock()
Release the restore lock without changing status payload.
public
releaseLock() : void
updateStatus()
Mark status as running and update current phase message.
public
updateStatus(string $phase, string $message[, array<string, mixed> $context = [] ]) : void
Parameters
- $phase : string
- $message : string
- $context : array<string, mixed> = []
clearExpiredLock()
Clear expired lock.
private
clearExpiredLock() : void
defaultStatus()
private
defaultStatus() : array<string, mixed>
Return values
array<string, mixed>isExpired()
Check if expired.
private
isExpired(string $isoValue) : bool
Parameters
- $isoValue : string
Return values
boolisoAfterSeconds()
Iso after seconds.
private
isoAfterSeconds(int $seconds) : string
Parameters
- $seconds : int
Return values
stringisOlderThanSeconds()
Check if older than seconds.
private
isOlderThanSeconds(string $isoValue, int $seconds) : bool
Parameters
- $isoValue : string
- $seconds : int
Return values
boollockKey()
Tenant-scoped restore lock cache key.
private
lockKey() : string
Return values
stringnowIso()
Now iso.
private
nowIso() : string
Return values
stringreadActiveLock()
private
readActiveLock() : array<string, mixed>|null
Return values
array<string, mixed>|nullreadStatus()
private
readStatus() : array<string, mixed>
Return values
array<string, mixed>statusKey()
Tenant-scoped restore status cache key.
private
statusKey() : string
Return values
stringwriteStatus()
private
writeStatus(array<string, mixed> $status) : void
Parameters
- $status : array<string, mixed>