\Drupal\strata\Tier TierTarget

Which bucket one tier writes to.

A tier is not a new kind of store. It is an existing provider pointed at a different location, so everything a provider already reports - its capabilities, its reachability, its request counts - keeps working unchanged. Only two things vary between tiers of the same provider in practice, and both are here: the bucket or directory, and the storage class objects land in.

The name is what a per-tier request count is filed under in ProviderStatStore, so it has to be unique, short and safe in a database column. It is normalised the same way a site id is, for the same reason.

Summary

Methods
Properties
Constants
__construct
address
isRelocated
fromSettings
normalise
jsonSerialize
name
provider
location
storageClass
MAX_NAME
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Constant

MAX_NAME

MAX_NAME = 48

Longest name a target may carry.

The ProviderStatStore provider column is 64 characters and the name is written into it, so a longer name would be truncated there and two tiers could collide on one row.

Properties

$name

$name : string

Type

string

$provider

$provider : string

Type

string

$location

$location : string

Type

string

$storageClass

$storageClass : string

Type

string

Methods

__construct()

__construct(string  $name, string  $provider, string  $location = '', string  $storageClass = '') : mixed

Constructs a target.

Parameters

string $name

Short unique token such as "near" or "year", used as the label and as the per-tier key in ProviderStatStore.

string $provider

Registered provider id the tier is built from, such as "local" or "s3".

string $location

Bucket name for an object store, or directory for the local provider. An empty string uses whatever that provider is already configured with, which is what a single-tier site wants.

string $storageClass

Storage class objects in this tier are written with, or an empty string for the endpoint default. Honoured only where Capabilities::$storageClasses is true; a provider that cannot store one refuses the write rather than dropping it.

Throws

\InvalidArgumentException

When the name is empty, longer than TierTarget::MAX_NAME, or normalises to nothing, or when the provider id is empty.

Returns

mixed —

address()

address() : string

The provider and location together, as one comparable token.

Two tiers pointing at the same bucket would make a move a no-op and a replica a claim about durability that is not true, so TierMap refuses a ladder where this repeats.

Returns

string —

Something such as "s3:strata-cold".

isRelocated()

isRelocated() : bool

Whether this target overrides where its provider writes.

Returns

bool —

TRUE when a location is set, so the provider has to be built for this tier rather than shared with the site's single configured one.

fromSettings()

fromSettings(array  $row, int  $index) : self

Builds a target from one settings row.

Parameters

array $row

One entry of the tiers.levels setting.

int $index

Position on the ladder, used to name a row that did not name itself.

Throws

\InvalidArgumentException

When the row names no provider.

Returns

self —

The target.

normalise()

normalise(string  $name) : string

Reduces a configured name to something safe in a database column and a report.

Parameters

string $name

The configured name.

Returns

string —

Lowercase, with everything but letters, digits, hyphens and underscores removed.

jsonSerialize()

jsonSerialize() : array<string,string>

{@inheritdoc}

Returns

array

The target as a plain array for a report table.