cayu.storage.product_operations_postgres
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
PostgresProductOperationStore
Section titled “PostgresProductOperationStore”from cayu.storage import PostgresProductOperationStoreTenant/resource authority shared by product service processes on PostgreSQL.
This store, not Cayu labels, metadata, or runtime identifiers, is the product authorization boundary. Product reads are tenant-qualified by public id; the private session-id lookup exists only for trusted continuation hooks.
Every claim, heartbeat, receipt, and settlement locks the one operation row and evaluates lease expiry against the database clock after that lock, so service processes on different hosts agree on ownership. Terminal updates are conditional on the current claim, and a completed result requires the content-bound publication receipt written before Cayu session completion.
cayu_product_operations joins Cayu’s shared revision history; like the
other Postgres stores, the default schema_mode is VALIDATE and
cayu storage migrate creates or upgrades the table. clock replaces
the database lease clock for tests.
Bases: _PostgresStoreBase.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
category |
ServiceIdentityStoreKind |
ServiceIdentityStoreKind.DURABLE |
init (method)
Section titled “init (method)”PostgresProductOperationStore.__init__(conninfo: str | None=None, *, pool: AsyncConnectionPool | None=None, min_size: int=1, max_size: int=8, schema_mode: schema.SchemaMode=schema.SchemaMode.VALIDATE, clock: Callable[[], datetime] | None=None) -> Noneensure_schema (method)
Section titled “ensure_schema (method)”async PostgresProductOperationStore.ensure_schema() -> NoneOpen the pool and reconcile the schema now (per schema_mode).
Normally reconciliation happens lazily on first use; the cayu storage
CLI calls this to run a migrate (or validate) as an explicit step.
close (method)
Section titled “close (method)”async PostgresProductOperationStore.close() -> Nonereserve (method)
Section titled “reserve (method)”async PostgresProductOperationStore.reserve(*, tenant_id: str, subject_id: str, idempotency_key: str, request_fingerprint: str, public_id: str, work_id: str, session_id: str, task_id: str, request_text: str) -> ProductOperationReservationfind (method)
Section titled “find (method)”async PostgresProductOperationStore.find(*, tenant_id: str, public_id: str) -> ProductOperation | Nonefind_by_session_id (method)
Section titled “find_by_session_id (method)”async PostgresProductOperationStore.find_by_session_id(*, session_id: str) -> ProductOperation | Noneclaim_execution (method)
Section titled “claim_execution (method)”async PostgresProductOperationStore.claim_execution(*, work_id: str, claim_id: str, lease_seconds: int) -> ProductOperationExecutionClaim | Noneheartbeat_execution (method)
Section titled “heartbeat_execution (method)”async PostgresProductOperationStore.heartbeat_execution(*, work_id: str, claim_id: str, lease_seconds: int) -> boolrelease_execution (method)
Section titled “release_execution (method)”async PostgresProductOperationStore.release_execution(*, work_id: str, claim_id: str) -> boolrecord_result_receipt (method)
Section titled “record_result_receipt (method)”async PostgresProductOperationStore.record_result_receipt(*, work_id: str, claim_id: str, receipt: ProductResultReceipt) -> ProductResultReceiptrecord_recovery_status (method)
Section titled “record_recovery_status (method)”async PostgresProductOperationStore.record_recovery_status(*, work_id: str, claim_id: str, recovery_status: ProductRecoveryStatus) -> ProductOperationfinish (method)
Section titled “finish (method)”async PostgresProductOperationStore.finish(*, work_id: str, claim_id: str, status: Literal['completed', 'failed'], result: str | None) -> ProductOperation