WorkerArrayStore
class WorkerArrayStore implements Store
Hold rate limiter state local to one cooperative worker.
Transitions must not introduce a suspension point because worker-local atomicity depends on each read, calculation, and write running to completion.
Traits
Properties
| protected array<string, array{value: int, secondary_value: int, expires_at: int}> | $states | The numeric rate limiter state held for this worker's lifetime. |
Methods
Calculate an admission decision and update accepted state values.
Calculate ordered group decisions against staged state.
Calculate a non-mutating policy inspection.
Calculate a cooldown extension and update its expiry.
Calculate a failure transition and update its state values.
Get the current epoch time in microseconds.
Consume all policies together, leaving state unchanged on denial.
Atomically extend a cooldown block.
Inspect a policy without mutating its state.
Clear the state for a physical limiter key.
Get the numeric state for a physical key.
Details
in
CalculatesRateLimits at line 27
protected LimitResult
calculateConsume(AdmissionPolicy $policy, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate an admission decision and update accepted state values.
in
CalculatesRateLimits at line 73
protected array
calculateMany(array $policies, int $now, array $states)
Calculate ordered group decisions against staged state.
in
CalculatesRateLimits at line 118
protected LimitResult|BackoffResult|CooldownResult
calculateInspection(AdmissionPolicy|Backoff|Cooldown $policy, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a non-mutating policy inspection.
in
CalculatesRateLimits at line 172
protected CooldownResult
calculateCooldownBlock(int $durationMicroseconds, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a cooldown extension and update its expiry.
in
CalculatesRateLimits at line 190
protected BackoffResult
calculateFailure(Backoff $backoff, int $now, int $value, int $secondaryValue, int $expiresAt)
Calculate a failure transition and update its state values.
in
CalculatesRateLimits at line 638
protected int
currentTimeInMicroseconds()
Get the current epoch time in microseconds.
at line 30
LimitResult
consume(string $key, AdmissionPolicy $policy)
Atomically consume capacity from an admission policy.
at line 59
array
consumeMany(array $policies)
Consume all policies together, leaving state unchanged on denial.
at line 87
CooldownResult
block(string $key, int $durationMicroseconds)
Atomically extend a cooldown block.
at line 113
LimitResult|BackoffResult|CooldownResult
inspect(string $key, AdmissionPolicy|Backoff|Cooldown $policy)
Inspect a policy without mutating its state.
at line 131
BackoffResult
recordFailure(string $key, Backoff $backoff)
Record a failure against a backoff policy.
at line 155
bool
clear(string $key)
Clear the state for a physical limiter key.
at line 171
protected array
state(string $key)
Get the numeric state for a physical key.