\Drupal\strata\Capture CaptureScope

Decides whether a given change is captured at all.

Read on every mutation, so every answer is resolved from configuration once per request and held. A scope check that hit the config system per entity save would cost more than the capture it guards.

Strata's own tables are never captured. Recording the journal in the journal, or the frame index in a frame, is an unbounded feedback loop rather than a backup.

Summary

Methods
Properties
Constants
__construct
isEnabled
covers
coversEntityType
coversTable
tapsStatements
coversTarget
accessChurnMode
reset
No public properties found
OWN_PREFIX
EXCLUDED_ENTITY_TYPES
No protected methods found
No protected properties found
No protected constants found
settings
resolved
resolving
configFactory
No private constants found

Constant

OWN_PREFIX

OWN_PREFIX = 'strata_'

Table prefix this module owns, never captured.

EXCLUDED_ENTITY_TYPES

EXCLUDED_ENTITY_TYPES = ['strata_commit', 'strata_frame']

Entity types whose saves describe Drupal's own bookkeeping rather than site content.

Properties

$resolved

$resolved : array|null

Resolved settings, or NULL until first read.

Type

array<string, mixed>|null —

$resolving

$resolving : bool

Whether the settings are being read right now.

Type

bool

$configFactory

$configFactory : \Drupal\Core\Config\ConfigFactoryInterface

Type

ConfigFactoryInterface

Methods

__construct()

__construct(\Drupal\Core\Config\ConfigFactoryInterface  $configFactory) : mixed

Constructs a scope.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $configFactory

Where the capture settings are read from.

Returns

mixed —

isEnabled()

isEnabled() : bool

Whether capture is switched on at all.

Returns

bool —

TRUE when the module is enabled for capture.

covers()

covers(\Drupal\strata\Journal\Realm  $realm) : bool

Whether a realm is captured.

Parameters

\Drupal\strata\Journal\Realm $realm

The realm.

Returns

bool —

TRUE when capture is on and this realm is included.

coversEntityType()

coversEntityType(string  $entityTypeId) : bool

Whether an entity type is captured.

Parameters

string $entityTypeId

The entity type id.

Returns

bool —

TRUE when the entity realm is covered and this type is not excluded.

coversTable()

coversTable(string  $table) : bool

Whether a table is captured.

Parameters

string $table

The table name.

Returns

bool —

TRUE when the table realm is covered and the table is not one of this module's own.

tapsStatements()

tapsStatements() : bool

Whether the raw SQL tap runs at all.

Separate from whether the table realm is captured, and deliberately so: the tap is the only driver-agnostic way to see a write nothing else instrumented, and it is also the only capture that adds cost to every statement a site runs rather than to every mutation. Measured at under 10 us per mutation, but a site that has calibrated and does not want it gets a switch that stops the events being enabled at all rather than one that filters afterwards.

Returns

bool —

TRUE when statement events should be enabled on the connection.

coversTarget()

coversTarget(string  $target) : bool

Whether a connection target is captured.

A replica target sees only reads by definition, so a write arriving on one is either a misconfiguration or a deliberate write to a secondary that the primary will not have. Neither belongs in the primary's history.

Parameters

string $target

The connection target, such as "default" or "replica".

Returns

bool —

TRUE when writes on this target are captured.

accessChurnMode()

accessChurnMode() : string

How a user access-timestamp touch is recorded.

Returns

string —

One of "delta" (a full field delta), "event" (a compact login event) or "drop".

reset()

reset() : void

Forgets the resolved settings.

Called by a test that changes configuration mid-run, and by a long command between batches.

Returns

void —

settings()

settings() : array<string,mixed>

The settings, resolved once.

??= assigns after its right-hand side has run, so during a cold read the memo is still NULL. A cold read of strata.settings misses cache_config and writes it back, that write is a MERGE, and MERGE is a write keyword the statement tap acts on - which asks this object what it covers, from inside the read that has not finished. The flag ends that walk rather than recursing. What makes it unreachable today is that StatementCaptureSubscriber::enable() resolves the scope before it enables the events, and that invariant lives in another class.

Returns

array

The raw settings array, or an empty one while a resolution is already in flight, which reads as "nothing is captured" and is the safe answer for a statement Strata itself caused.