\Drupal\strata\Site SiteScopedProvider

Confines one site's reads and writes to its own namespace.

Multi-site isolation is enforced here rather than in every caller. The commit log, the segment writer, the tree builder and the ref store all compose their own keys, and asking each of them to remember a site prefix would mean one that forgot became a site reading another's history.

Wrapping the provider instead means there is exactly one place the prefix is applied and exactly one place it is stripped, and a listing cannot return a key belonging to another site because the listing itself is prefixed.

Frames are NOT confined, and that is the point of sharing a bucket. A frame is addressed by the digest of its content, so two sites storing the same config object store one frame; confining frames per site would turn the saving into duplication. Only the things that describe a site - commits, refs, trees, segments - are namespaced.

Summary

Methods
Properties
Constants
__construct
id
label
capabilities
isReachable
unreachableReason
put
get
stream
head
exists
delete
list
unscoped
isShared
No public properties found
SHARED_PREFIXES
No protected methods found
No protected properties found
No protected constants found
scope
unscope
inner
site
No private constants found

Constant

SHARED_PREFIXES

SHARED_PREFIXES = ['frames/', 'packs/', 'media/', 'dicts/']

Key prefixes shared across every site in a bucket.

Content, addressed by its own digest. Two sites holding the same bytes hold them once.

Properties

$site

$site : \Drupal\strata\Site\SiteContext

Type

SiteContext

Methods

__construct()

__construct(\Drupal\strata\Storage\StorageProviderInterface  $inner, \Drupal\strata\Site\SiteContext  $site) : mixed

Constructs a scoped provider.

Parameters

\Drupal\strata\Storage\StorageProviderInterface $inner

The provider being wrapped.

\Drupal\strata\Site\SiteContext $site

Which site's namespace to use.

Returns

mixed —

id()

id() : string

The plugin id this provider registers under.

Returns

string —

A short lowercase token such as "s3", "r2", "sftp" or "local".

label()

label() : string

Human-readable name for the settings form.

Returns

string —

The label.

capabilities()

capabilities() : \Drupal\strata\Storage\Capabilities

What this endpoint can do.

Returns

\Drupal\strata\Storage\Capabilities —

The capability set.

isReachable()

isReachable() : bool

Whether the endpoint is reachable and the credentials work.

Returns

bool —

TRUE when a request would succeed right now.

unreachableReason()

unreachableReason() : string|null

Why the endpoint is unreachable.

Returns

string|null —

A short human-readable reason, or NULL when it is reachable.

put()

put(string  $key, mixed  $body, array  $options = []) : \Drupal\strata\Storage\PutResult

Writes an object.

Parameters

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. ifNoneMatch (write only when the key is absent) is honoured wherever Capabilities::$conditionalWrite is true. metadata, contentType and storageClass are honoured only by providers whose endpoint carries them; a provider that cannot store an option refuses the write rather than dropping it, because an object written without the metadata its reader expects is indistinguishable from a corrupt one. Nothing in the engine depends on user metadata: a stored object carries whatever a reader needs in its own bytes.

Returns

\Drupal\strata\Storage\PutResult —

What was written.

get()

get(string  $key, ?\Drupal\strata\Storage\ByteRange  $range = null) : string

Reads an object.

Parameters

string $key

Object key relative to the store root.

?\Drupal\strata\Storage\ByteRange $range

A byte range, or NULL for the whole object.

Returns

string —

The bytes.

stream()

stream(string  $key) : resource

Opens an object as a stream.

Parameters

string $key

Object key relative to the store root.

Returns

resource —

An open readable stream the caller must close.

head()

head(string  $key) : \Drupal\strata\Storage\ObjectMeta|null

Metadata for one object without reading it.

Parameters

string $key

Object key relative to the store root.

Returns

\Drupal\strata\Storage\ObjectMeta|null —

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.

exists()

exists(string  $key) : bool

Whether an object exists.

Parameters

string $key

Object key relative to the store root.

Returns

bool —

TRUE when it is present.

delete()

delete(array  $keys) : int

Deletes objects.

Parameters

array $keys

Object keys relative to the store root.

Returns

int —

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()

list(string  $prefix = '', ?string  $cursor = null, int  $limit = 1000, ?string  $delimiter = null) : \Drupal\strata\Storage\ObjectPage

Lists one page of objects under a prefix.

Parameters

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.

Returns

\Drupal\strata\Storage\ObjectPage —

The page.

unscoped()

unscoped() : \Drupal\strata\Storage\StorageProviderInterface

The provider this wraps.

Returns

\Drupal\strata\Storage\StorageProviderInterface —

The inner provider, for a caller that genuinely needs the whole bucket - a bucket-wide usage report, or a listing of which sites are present.

isShared()

isShared(string  $key) : bool

Whether a key is shared across sites rather than namespaced.

Parameters

string $key

The key.

Returns

bool —

TRUE when the key addresses content by its own digest.

scope()

scope(string  $key) : string

A key inside this site's namespace, unless it is shared.

Parameters

string $key

The key as the caller composed it.

Returns

string —

The key to use against the inner provider.

unscope()

unscope(string  $key) : string|null

A key as the caller would have composed it.

Parameters

string $key

The key from the inner provider.

Returns

string|null —

The unscoped key, or NULL when it belongs to a different site.