$clock
$clock : \Closure
Returns the current time in seconds as a float.
Wraps any provider and records what every call to it cost.
The engine asks a store for objects and gets no bill back. This decorator sits between the two and writes each request into a ProviderStats, so a budget reading is taken from the requests that were actually issued rather than from an estimate of how many a flush should have needed.
Two verbs are recorded under the name of the request they really make, because that is what the endpoint charges for:
A delete counts once per call rather than once per key: a provider that batches sends one request for the whole array, and the array size is visible in the caller's own code.
Identity is forwarded untouched. Reading an id, a label, a capability set or a reachability flag either costs nothing or is already cached by the provider, and counting a settings-form render as store traffic would put the budget guard on the wrong side of the numbers.
A failure is recorded and rethrown. Nothing is swallowed; a caller that cannot tell a failed write from a successful one has no way to keep its own state honest.
$inner : \Drupal\strata\Storage\StorageProviderInterface
$stats : \Drupal\strata\Storage\ProviderStats
__construct(\Drupal\strata\Storage\StorageProviderInterface $inner, \Drupal\strata\Storage\ProviderStats $stats, callable|null $clock = null) : mixed
Constructs the decorator.
| \Drupal\strata\Storage\StorageProviderInterface | $inner | The provider every call is forwarded to. |
| \Drupal\strata\Storage\ProviderStats | $stats | The accumulator to write into. Sharing one accumulator across several decorators totals them; giving each its own keeps them separate. |
| callable|null | $clock | Returns seconds as a float or an int. NULL uses microtime(true). Injected so a test can assert an exact duration instead of sleeping for one. |
inner() : \Drupal\strata\Storage\StorageProviderInterface
The provider every call is forwarded to.
Exposed for the same reason SiteScopedProvider::unscoped() is: code that has to know which endpoint is really configured should not have to match on a decorator.
The wrapped provider.
put(string $key, mixed $body, array $options = []) : \Drupal\strata\Storage\PutResult
Writes an object.
| string | $key | Object key relative to the store root. |
| mixed | $body | The bytes, or an open readable stream. A stream is read once and not rewound, so a caller that needs it again must seek itself. |
| array | $options | Provider options. |
What was written.
delete(array $keys) : int
Deletes objects.
| array | $keys | Object keys relative to the store root. |
How many keys the endpoint accepted. A store that can tell an absent key from a removed one counts only what it removed; S3 reports success for an absent key and cannot distinguish, so it counts everything it was given. Do not read this as "how many existed" - a prune receipt counts from the frame index, which knows.
list(string $prefix = '', ?string $cursor = null, int $limit = 1000, ?string $delimiter = null) : \Drupal\strata\Storage\ObjectPage
Lists one page of objects under a prefix.
| string | $prefix | Key prefix relative to the store root; an empty string lists everything. |
| ?string | $cursor | Continuation token from a previous page, or NULL to start. |
| int | $limit | Most objects to return in this page. |
| ?string | $delimiter | Grouping delimiter, or NULL for a flat listing. |
The page.
head(string $key) : \Drupal\strata\Storage\ObjectMeta|null
Metadata for one object without reading it.
| string | $key | Object key relative to the store root. |
The metadata, or NULL when the object is absent. Absence is not an error, because every caller of this method is asking precisely in order to find out.
recordFailure(string $operation, float $started) : void
Records a failed attempt.
No byte count, because a request that raised gives no honest one back; the failure count is what tells an operator the requests were spent on nothing.
| string | $operation | The billed verb the call maps to. |
| float | $started | Clock reading taken before the call. |
elapsed(float $started) : float
How long a call took.
Clamped at zero. A clock that steps backwards - an ntp correction, or a test clock rewound between reads - would otherwise make ProviderStats::record() raise on top of whatever the call itself was doing, replacing the real error with a bookkeeping one.
| float | $started | Clock reading taken before the call. |
Seconds elapsed, never negative.
now() : float
Reads the injected clock.
When the injected clock returns anything but a number. Caught here rather than left to the subtraction, where a string clock would turn every duration into zero.
Seconds. An int reading is widened, so a test clock counting whole seconds works.