PREFIX
PREFIX = 'segments'
Key prefix segments are written under.
Writes a segment manifest to the store.
A manifest goes through the same compression and sealing as a payload frame, because it names every subject that changed and what the change was; an unsealed manifest would leak the shape of the site to anyone with read access to the bucket even if every frame were encrypted.
The stored object is self-describing: a short plaintext header naming the format version, the codec and the plaintext digest, followed by the sealed body. Nothing about reading it depends on provider metadata, which not every endpoint returns and which the local filesystem has nowhere to put. The object KEY is the associated data, so a segment moved to another key fails to open instead of opening as the wrong segment.
The key carries the level and the time range rather than only a digest, so a compaction pass can find the segments covering an hour with one prefix listing rather than reading manifests.
$provider : \Drupal\strata\Storage\StorageProviderInterface
$codecs : \Drupal\strata\Codec\CodecRegistry
$cipher : \Drupal\strata\Crypto\CipherInterface
__construct(\Drupal\strata\Storage\StorageProviderInterface $provider, \Drupal\strata\Codec\CodecRegistry $codecs, \Drupal\strata\Crypto\CipherInterface $cipher, int|null $level = null) : mixed
Constructs a writer.
| \Drupal\strata\Storage\StorageProviderInterface | $provider | Where segments are written. |
| \Drupal\strata\Codec\CodecRegistry | $codecs | Used to pick the codec that compresses the manifest. |
| \Drupal\strata\Crypto\CipherInterface | $cipher | Seals the manifest. |
| int|null | $level | Compression level, or NULL for the codec's default. |
write(\Drupal\strata\Segment\SegmentManifest $manifest, int|null $second = null) : string
Writes a manifest and returns its object key.
| \Drupal\strata\Segment\SegmentManifest | $manifest | The manifest. |
| int|null | $second | The epoch second to file the segment under, or NULL to take it from the first operation. A rollup supplies the coarse window's start, because a segment covering an hour belongs to that hour rather than to the second its earliest operation happened to land in. |
When the manifest is empty, or the write fails.
When the manifest holds a string JSON cannot represent. JournalOp refuses such a string on
capture, so reaching this is a bug rather than bad input; without it (string) false would
seal an empty object under Hash::of('') and the flush would report success.
The object key the segment was written to.
header(string $codec, string $cipher, string $digest) : string
The plaintext header leading a stored segment.
Newline delimited so a reader can find the body without a length prefix, and plaintext because a reader must know which codec and cipher to use before it can open anything.
| string | $codec | Codec id the body was compressed with. |
| string | $cipher | Cipher id the body was sealed with. |
| string | $digest | Digest of the serialized manifest, before compression. |
The header, ending in a newline.
key(\Drupal\strata\Segment\SegmentManifest $manifest, string $digest, int|null $second = null) : string
The object key a manifest is written to.
Shaped segments/<level>/<epoch-second>/<sequence>-<digest>.seg. The level and the epoch
second are directories so a compaction pass can list one hour at one level directly; the
sequence leads the filename so a listing comes back in capture order.
| \Drupal\strata\Segment\SegmentManifest | $manifest | The manifest. |
| string | $digest | Digest of the serialized manifest. |
| int|null | $second | The epoch second to file it under, or NULL to take it from the first operation. |
The object key.