\Drupal\strata\Drush\Commands StrataDiagnosticCommands

The commands that measure rather than change.

A backup is only a backup if it reads back, so strata:verify fetches and decodes what the store holds and names everything that does not come out. strata:audit and strata:heal read the record that pass leaves behind: which findings are outstanding, and how far up the repair ladder each finding code has climbed. Nothing here takes a rung above the automatic ceiling on its own; quarantine and refuse remove a restore target, and strata:quarantine is where a person asks for that.

strata:estimate and strata:calibrate answer the two cost questions. The estimate projects a bill from a site's shape and the policy applied to it. The calibration measures what the codecs on this host actually achieve on this site's own payloads, and marks its figures as measured so they are never confused with the shipped reference numbers.

Summary

Methods
Properties
Constants
__construct
verify
auditLog
heal
tiers
classify
estimate
calibrate
No public properties found
No public constants found
value
number
flag
ref
prose
agreed
announce
bytes
moment
digest
duration
yesNo
No protected properties found
No protected constants found
tierRequirements
tierMode
ladder
moveTo
runPass
passFor
samples
measure
megabytesPerSecond
source
printComponents
decide
severityName
engine
configFactory
ledger
audit
classifications
No private constants found

Properties

$engine

$engine : \Drupal\strata\Engine

Type

Engine

$configFactory

$configFactory : \Drupal\Core\Config\ConfigFactoryInterface

Type

ConfigFactoryInterface

$audit

$audit : \Drupal\strata\Restore\RestoreAudit

Type

RestoreAudit

$classifications

$classifications : \Drupal\strata\Capture\Classifier\ClassificationRegistry

Type

ClassificationRegistry

Methods

__construct()

__construct(\Drupal\strata\Engine  $engine, \Drupal\Core\Config\ConfigFactoryInterface  $configFactory, \Drupal\strata\Health\HealthLedgerInterface  $ledger, \Drupal\strata\Restore\RestoreAudit  $audit, \Drupal\strata\Capture\Classifier\ClassificationRegistry  $classifications) : mixed

Constructs the command set.

Parameters

\Drupal\strata\Engine $engine

Builds the verifier, the discovery pass and the codec registry.

\Drupal\Core\Config\ConfigFactoryInterface $configFactory

Supplies the policy dials an estimate defaults to.

\Drupal\strata\Health\HealthLedgerInterface $ledger

Holds the findings and the rung each code sits at.

\Drupal\strata\Restore\RestoreAudit $audit

Holds the record of every restore this site has run.

\Drupal\strata\Capture\Classifier\ClassificationRegistry $classifications

Holds what each part of the ephemeral keyspace has been decided to be.

Returns

mixed —

verify()

verify(array  $options = ['ref' => \Drupal\strata\Tree\RefStore::MAIN, 'limit' => 0, 'shallow' => false]) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Reads the backup back and names what does not come out.

A deep pass fetches and decodes every frame, which is the only check that proves the bytes are still there and still decode. A shallow pass asks only whether each object is present and indexed, at one head request per object instead of a fetch and a decode.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per finding, empty when everything the pass touched read back correctly.

auditLog()

auditLog(array  $options = ['limit' => 50, 'unfinished' => false]) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Every restore this site has run, newest first.

A restore that is still recorded as pending outlived the process that started it, so those are reported first: the site may hold a partial write nobody has reconciled.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per restore, empty on a site that has never restored anything.

heal()

heal(string|null  $code = null, array  $options = ['list' => false, 'apply' => false, 'rung' => \self::REQ, 'decay' => false]) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Reports where each finding code sits on the repair ladder, and runs the pass its rung names.

Rungs run cheapest and most reversible first, and a code moves one rung at a time so an operator can watch it climb. Everything at or below "rebuild" reconstructs derived state from data that still exists, so the worst case of running it wrongly is wasted work; that is the ceiling an unattended run may reach. Moving a code to quarantine or refuse takes a restore target away, so it is reachable only through an explicit --rung with a confirmation.

Parameters

string|null $code

The finding code to act on, or NULL to report every open code.

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per open finding code, empty when nothing is outstanding.

tiers()

tiers(array  $options = ['restore' => \self::REQ]) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Reports what each storage tier holds, whether it answers, and what a restore would need.

Two questions an operator cannot answer from anywhere else. The first is where history actually is, which matters because a bucket that is meant to be cold and is holding nothing means the migration has never run. The second is which buckets a rollback needs, and the point of asking it here is to find out before starting rather than halfway through.

An object with no recorded tier is counted as unplaced rather than assumed to be nearby. While there is one, every tier is reported as possibly needed, because that is the true answer.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per tier, empty when the site writes to a single bucket.

classify()

classify(array  $options = ['limit' => 10000, 'skip-discovery' => false, 'pattern' => \self::REQ, 'decide' => \self::REQ]) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Reports what the ephemeral keyspace holds and which patterns still need a decision.

Caches, sessions, locks and queues are not one thing. Some of it is the only copy of something the site needs and some rebuilds itself the moment it is asked for. Anything the heuristics cannot place is captured verbatim and listed here, busiest first, because a pattern covering two million keys is the one worth deciding.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per classification, plus a row per pattern still undecided.

estimate()

estimate(array  $options = ['users' => 0, 'nodes' => 0, 'rows' => 0, 'files' => 0, 'file-bytes' => 0, 'active-share' => \self::REQ, 'retention' => 365, 'deploys' => 150, 'interval' => \self::REQ, 'access-churn' => \self::REQ]) : \Consolidation\OutputFormatters\StructuredData\PropertyList

Projects what a site of a given shape costs to keep.

The shape decides how much churn there is and the policy decides what that churn costs, so a site twice the size on half the flush interval is not twice the bill. The policy dials default to what this site is configured for, which makes the projection a statement about this installation rather than about an imaginary one.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\PropertyList —

The projection.

calibrate()

calibrate(array  $options = ['ref' => \Drupal\strata\Tree\RefStore::MAIN, 'samples' => 200, 'level' => 'dense']) : \Consolidation\OutputFormatters\StructuredData\RowsOfFields

Measures what each codec on this host achieves on this site's own payloads.

A compression ratio depends on content, so the shipped figures exist to let two hosts be compared and to give a size estimate somewhere to start. This measures the real thing, and marks every row it produced as measured here so it is never read as a shipped number. A site with no history yet has nothing to sample, and the reference figures are reported instead.

Parameters

array $options

Command options.

Returns

\Consolidation\OutputFormatters\StructuredData\RowsOfFields —

One row per codec.

value()

value(array  $options, string  $name) : string|null

Reads an option that carries a value.

A value option declares DrushCommands::REQ as its default, and Drush replaces that with the string the operator supplied or with NULL before the command body runs. A method called directly - from a test, a hook, or another command - still sees the sentinel, and both forms mean that nothing was supplied. Drush only ever passes a string, so an integer sentinel cannot be confused with a value.

Parameters

array $options

The options the command was called with.

string $name

The option name.

Returns

string|null —

The value, or NULL when none was supplied.

number()

number(array  $options, string  $name, int  $fallback) : int

Reads an option that carries a whole number.

Parameters

array $options

The options the command was called with.

string $name

The option name.

int $fallback

What to return when nothing was supplied.

Returns

int —

The value, or the fallback.

flag()

flag(array  $options, string  $name) : bool

Whether a flag was given.

Parameters

array $options

The options the command was called with.

string $name

The option name.

Returns

bool —

TRUE when the flag was supplied.

ref()

ref(array  $options) : string

The ref an option set names.

Parameters

array $options

The options the command was called with.

Returns

string —

The ref name, or the main ref when none was supplied.

prose()

prose() : \Symfony\Component\Console\Style\SymfonyStyle

The style prose is written to.

Returns

\Symfony\Component\Console\Style\SymfonyStyle —

A style over standard error.

agreed()

agreed(string  $question) : bool

Asks before doing something that removes a restore target or overwrites live data.

Drush answers this itself under --yes and --no, so a scripted run never blocks. The default is no, because the question is only ever asked about something irreversible.

Parameters

string $question

What is about to happen, phrased as a question.

Returns

bool —

TRUE to go ahead.

announce()

announce(bool  $acted, string  $summary) : void

States what a pass did, at the severity the outcome deserves.

A pass that ran and a pass that declined to run both produce a summary worth reading, and the difference between them is what an operator watching a scheduled job needs to see.

Parameters

bool $acted

TRUE when the pass did the thing it was asked to do.

string $summary

The one-line summary to print.

Returns

void —

bytes()

bytes(int  $bytes) : string

Renders a byte count at a readable scale.

Parameters

int $bytes

The count.

Returns

string —

For example "4.0 MiB".

moment()

moment(int  $microtime) : string

Renders unix microseconds as a timestamp.

Parameters

int $microtime

Microseconds since the epoch, or zero for no moment at all.

Returns

string —

An ISO-8601 timestamp, or "-".

digest()

digest(string|null  $digest) : string

Shortens a content address for a table cell.

Anything that is not a digest is returned whole, so an object key or a refusal reason passed here is readable rather than truncated to twelve characters of a path.

Parameters

string|null $digest

The digest, or NULL.

Returns

string —

The first twelve characters of a digest, the value unchanged when it is not one, or "-".

duration()

duration(float  $seconds) : string

Renders a duration.

Parameters

float $seconds

The duration.

Returns

string —

For example "1.24s".

yesNo()

yesNo(bool  $value) : string

Renders a boolean as a word.

Parameters

bool $value

The value.

Returns

string —

Either "yes" or "no".

tierRequirements()

tierRequirements(array  $options) : array<int,array<string,mixed>>|null

Which tiers a named restore would read.

Parameters

array $options

Command options.

Returns

array>|null —

Tier rows keyed by index, or NULL when no commit was named.

tierMode()

tierMode(\Drupal\strata\Tier\Tier  $tier) : string

Whether a tier keeps the copy below it.

Parameters

\Drupal\strata\Tier\Tier $tier

The tier.

Returns

string —

A short word for the column.

ladder()

ladder() : array<string,array<string,string|int>>

Every open finding code with where it sits and what its rung would run.

Returns

array> —

Code keyed to its row.

moveTo()

moveTo(string  $code, string  $rung) : void

Moves a code to a rung, asking first when the rung removes a restore target.

Parameters

string $code

The finding code.

string $rung

The rung to move to.

Returns

void —

runPass()

runPass(string  $code) : void

Runs the repair pass a code's current rung names.

Parameters

string $code

The finding code.

Returns

void —

passFor()

passFor(string  $rung) : string

The pass a rung names.

Parameters

string $rung

The rung.

Returns

string —

What running the rung does.

samples()

samples(string  $ref, int  $limit) : list<string>

Payload samples to compress, newest first.

Parameters

string $ref

Ref to collect from.

int $limit

Most payloads to return.

Returns

list

The payloads, empty when there is no readable history.

measure()

measure(\Drupal\strata\Codec\CompressionCodecInterface  $codec, int  $level, int  $frameSize, list  $samples) : \Drupal\strata\Codec\CodecMeasurement|null

Compresses and decompresses a sample set, timing both directions.

Parameters

\Drupal\strata\Codec\CompressionCodecInterface $codec

The codec to measure.

int $level

The level to measure at.

int $frameSize

The configured frame size, recorded with the figure.

list $samples

The payloads.

Returns

\Drupal\strata\Codec\CodecMeasurement|null —

The figure, or NULL when the codec could not run.

megabytesPerSecond()

megabytesPerSecond(int  $bytes, float  $seconds) : float

A throughput figure.

Parameters

int $bytes

Bytes processed.

float $seconds

How long it took.

Returns

float —

Megabytes a second, or zero when the run was too short to time.

source()

source(\Drupal\strata\Codec\CodecMeasurement|null  $measurement) : string

Where a figure came from.

Parameters

\Drupal\strata\Codec\CodecMeasurement|null $measurement

The figure, or NULL when there is none.

Returns

string —

Either "measured here", "reference" or "-".

printComponents()

printComponents(\Drupal\strata\Estimate\Projection  $projection) : void

Prints what each component of a projection contributes.

Parameters

\Drupal\strata\Estimate\Projection $projection

The projection.

Returns

void —

decide()

decide(string  $pattern, string  $decision) : void

Records a human decision about a key pattern.

Parameters

string $pattern

The key pattern.

string $decision

A classification value.

Returns

void —

severityName()

severityName(int  $severity) : string

The name of a severity ordinal.

Parameters

int $severity

One of the Finding severity ordinals.

Returns

string —

The name, or "INFO" for an ordinal below the lowest named one.