pub struct RecordPrecondition {
pub capability: String,
pub key: String,
pub require_absent: bool,
pub expected_version: Option<u64>,
pub expected_epoch: Option<u64>,
pub expected_lease_id: Option<String>,
}Expand description
What must be true of one record for a transaction to commit.
Distinct from AtomicPrecondition, and deliberately so. That one compares
the row’s internal operation sequence, and None on it means “this record
must not exist”. This one compares the fields a caller can actually read
back – the document’s __version, its authority epoch, its lease – which
are the same fields single-record CAS compares. Plumbing a caller’s
expectedVersion into the sequence check would have compared a document
version against a storage sequence: two different numbers that happen to
share a name.
Every predicate is optional and only a supplied one is checked. That differs
from CAS, where an absent expected_lease_id asserts the record is not
leased; here an absent predicate asserts nothing at all. The difference is
deliberate – a transaction precondition is a fence the caller opts into,
not a full description of the record – and it is why the fields are named
expected_* rather than describing a state.
Fields§
§capability: String§key: String§require_absent: boolThe record must not exist. Mutually exclusive with the predicates below.
expected_version: Option<u64>The document’s __version, as updateIfVersion compares it.
expected_epoch: Option<u64>The record’s authority epoch, at /authority/epoch.
expected_lease_id: Option<String>The id of an unexpired lease held on the record.