\Drupal\strata\Health TripwireRegistry

The one place tripwires are enumerated, and the sweep that runs them.

Registration is keyed by the tripwire's own code, so the registry cannot end up holding two checks that report under the same identifier - the ledger, the ladder and the circuit breaker all key on that code, and two sources feeding one key makes every count downstream wrong.

The sweep is the part that has to be hard to break. A tripwire that throws is caught and turned into a finding of its own, because the alternative is that one broken check hides every check registered after it, and the checks that stop reporting are exactly the ones nobody notices have gone quiet.

Summary

Methods
Properties
Constants
withStorageTripwires
withCaptureTripwires
withFileTripwires
register
has
get
codes
all
evaluate
No public properties found
FAILED
No protected methods found
No protected properties found
No protected constants found
No private methods found
wires
No private constants found

Constant

FAILED

FAILED = 'tripwire.failed'

Code reported when a tripwire throws instead of answering.

The failing tripwire's own code goes in the finding's scope, so one broken check is attributable without needing a code per tripwire for the same failure mode.

Properties

$wires

$wires : array

The registered tripwires, keyed by code, in registration order.

Type

array<string|int, mixed> —

Methods

withStorageTripwires()

withStorageTripwires() : self

A registry holding every check over what is in the object store.

The set a verify pass sweeps with. Ordered cheapest-first only incidentally; every one of them reads the observation it is handed and nothing else, so the order does not change the result.

Returns

self —

A populated registry.

withCaptureTripwires()

withCaptureTripwires() : self

A registry holding the checks over whether capture saw everything.

Separate from the storage set because it answers a different question. The storage checks ask whether what was stored is intact; this one asks whether anything was missed, which is the only failure a backup system cannot see from inside its own capture path.

Returns

self —

A populated registry.

withFileTripwires()

withFileTripwires() : self

A registry holding the checks over the file realm.

Its own set because the file realm's failure is neither corruption nor a gap: the content is stored and restores exactly, and it simply costs far more than it should because fixed blocks cannot follow a shift.

Returns

self —

A populated registry.

register()

register(\Drupal\strata\Health\TripwireInterface  $wire) : self

Registers a tripwire under its own code.

Parameters

\Drupal\strata\Health\TripwireInterface $wire

The tripwire.

Throws

\InvalidArgumentException

When the code is empty, or something is already registered under it. Both are refused loudly rather than resolved by last-write-wins, which would silently drop a check.

Returns

self —

This registry, so a set can be built in one expression.

has()

has(string  $code) : bool

Whether a code is registered.

Parameters

string $code

The tripwire code.

Returns

bool —

TRUE when a tripwire is registered under this code.

get()

get(string  $code) : \Drupal\strata\Health\TripwireInterface|null

One registered tripwire.

Returns NULL rather than throwing, so a caller checking whether an optional check is installed does not need a try block to ask.

Parameters

string $code

The tripwire code.

Returns

\Drupal\strata\Health\TripwireInterface|null —

The tripwire, or NULL when nothing is registered under that code.

codes()

codes() : array

Every registered code, in registration order.

Returns

array —

The codes.

all()

all() : array

Every registered tripwire, keyed by code, in registration order.

Returns

array —

Code to TripwireInterface.

evaluate()

evaluate(array  $observation) : \Drupal\strata\Health\Finding[]

Runs every tripwire over one observation and collects what fired.

The sweep never aborts. A tripwire that throws becomes a FAILED finding scoped to that tripwire's code and the sweep continues, so a bug in one check costs one check.

Parameters

array $observation

Scalars the caller already had; passed to every tripwire unchanged.

Returns

\Drupal\strata\Health\Finding[] —

Findings in registration order, empty when everything is satisfied.