Download this file
| 1 | package hostclaim |
| 2 | |
| 3 | // IsOrphan is §5.1 step 5. The caller reads the record FIRST and this |
| 4 | // claim AFTER it (R3-2). Each incarnation gets exactly one claim attempt, |
| 5 | // and a record exists only after that attempt succeeded, so a claim read |
| 6 | // after the record that does not name recordInc means recordInc can never |
| 7 | // become the holder. A creating holder is named by Holder, so it is |
| 8 | // covered. An absent claim is a legacy host (Q2), never an orphan. The |
| 9 | // caller deletes only with DeleteIfMatch on the ETag it read. |
| 10 | func IsOrphan(recordInc string, claimReadAfterRecord Observed) bool { |
| 11 | if claimReadAfterRecord.Absent || claimReadAfterRecord.Claim == nil { |
| 12 | return false |
| 13 | } |
| 14 | h := claimReadAfterRecord.Claim.Holder |
| 15 | return h == nil || h.Incarnation != recordInc |
| 16 | } |
| 17 | |