arm_read_owner(domain: Any, journal: Any, scope: Any, owner: Any, revision: int) -> None
Lock the exact, uncompleted owned claim on the open read transaction.
The FOR UPDATE row lock holds until the read commits, so no journal unit
of this invocation can advance its revision while candidates are read.
Source code in src/symfonic/memory/backends/postgres_receipt_views.py
| async def arm_read_owner(
domain: Any, journal: Any, scope: Any, owner: Any, revision: int,
) -> None:
"""Lock the exact, uncompleted owned claim on the open read transaction.
The FOR UPDATE row lock holds until the read commits, so no journal unit
of this invocation can advance its revision while candidates are read.
"""
from symfonic.memory.backends import postgres_operation_journal_codec as codec
from symfonic.memory.backends.pool_transaction import bound_connection
from symfonic.memory.backends.postgres_operation_journal import PostgresOperationJournal
from symfonic.memory.backends.postgres_operation_receipt import PostgresReceiptDomain
from symfonic.memory.storage_scope import NativeStorageScope
if (
type(domain) is not PostgresReceiptDomain
or type(journal) is not PostgresOperationJournal
or journal._domain is not domain
or journal._uncertain
or scope != NativeStorageScope.from_scope(owner.full_scope)
):
raise MemoryContractError("PostgreSQL receipt read owner refused")
conn = bound_connection(domain.pool)
if conn is None:
raise MemoryContractError("PostgreSQL receipt read owner needs its transaction")
expected, verifier, expected_revision = journal._owner_binding(owner, revision)
await codec.owned(conn, expected, verifier, expected_revision)
|