NAME
Net::Blossom::Server::MetadataStore - Metadata storage contract for Blossom backends
DESCRIPTION
Net::Blossom::Server::MetadataStore documents and validates the metadata component used by a Blossom storage backend. A metadata store manages blob records and owner records, but never stores blob bytes.
Blob records are hash references with sha256, storage_key, size, type, and uploaded values. storage_key is an opaque identifier owned by the corresponding blob store.
lock_blob and every method that changes records must be called from a with_transaction callback. Database implementations must reject those calls when the transaction is not active.
METHODS
deploy_schema
Creates the metadata tables and indexes. It must be safe to call repeatedly.
with_transaction
my $result = $metadata->with_transaction(sub { ... });
Runs the callback in a transaction, committing its result or rolling it back when the callback dies.
lock_blob
$metadata->lock_blob($sha256);
Prevents concurrent changes for the same hash from interleaving within the current transaction. It may be a no-op only when the transaction model already provides that serialization.
find_blob
my $record = $metadata->find_blob($sha256);
Returns a blob record or undef.
insert_blob
my $created = $metadata->insert_blob(%record);
Inserts a blob record and returns true when it was created or false when the hash already exists.
upsert_owner
$metadata->upsert_owner(%owner);
Creates or updates the owner identified by pubkey and sha256. Owner data also includes type and uploaded.
delete_owner
my $deleted = $metadata->delete_owner($sha256, $pubkey);
Deletes one owner relationship and reports whether it existed.
delete_owners
$metadata->delete_owners($sha256);
Deletes every owner relationship for a blob.
owner_count
my $count = $metadata->owner_count($sha256);
Returns the number of owners for a blob.
delete_blob
my $deleted = $metadata->delete_blob($sha256);
Deletes one blob record and reports whether it existed.
list_blobs
my $records = $metadata->list_blobs($pubkey, %options);
Returns blob records for an owner using the ordering, cursor, and limit rules from Net::Blossom::Server::Storage.
required_methods
Returns the method names required from a metadata store.
assert_implements
Net::Blossom::Server::MetadataStore->assert_implements($metadata);
Croaks unless $metadata is an object implementing the contract.