RestoreStatusService
in package
Tracks restore lock and restore progress in shared cache.
Table of Contents
Constants
- CACHE_CONFIG = 'restore_status'
- DEFAULT_LOCK_TTL_SECONDS = 1800
- LOCK_KEY = 'restore.lock'
- STALE_PROGRESS_SECONDS = 180
- STATUS_KEY = 'restore.status'
Methods
- acquireLock() : bool
- Acquire restore lock and initialize running status.
- 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.
- nowIso() : string
- Now iso.
- readActiveLock() : array<string, mixed>|null
- readStatus() : array<string, mixed>
- 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'
STALE_PROGRESS_SECONDS
private
mixed
STALE_PROGRESS_SECONDS
= 180
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
boolgetStatus()
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
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
boolnowIso()
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>writeStatus()
private
writeStatus(array<string, mixed> $status) : void
Parameters
- $status : array<string, mixed>