Documentation
¶
Overview ¶
Package claimstracker records which steps a replica has a claim CAS in flight on, so a sibling worker that pops the same candidate can skip it instead of paying a round trip to lose the CAS.
if !tracker.TryClaim(shard, stepID) {
continue // a sibling worker in this replica is already claiming it
}
It is strictly ADVISORY: the claim CAS remains the only thing that grants a step, so a missed or stale entry costs a wasted round trip or a deferred dispatch, never correctness. It is safe for concurrent use.
A reservation EXPIRES ON ITS OWN, between one and two seconds after it was taken - long enough to outlast the interval between candidate scans, far short of the lease margin. Nothing has to release one, and RelinquishClaim exists only for a caller that knows a step is settled sooner than that and wants the entry gone now. Any path that re-offers a step to THIS replica must call it, or the replica skips its own re-dispatch until the entry ages out.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker is the two-generation in-flight set. Safe for concurrent use.
func (*Tracker) RelinquishClaim ¶
RelinquishClaim drops a reservation from both generations. Nothing on the dispatch path needs to call it - reservations expire on their own roll - it exists for a caller that knows a step is settled sooner than the window and wants the entry gone now. It does not roll the maps: deleting from a stale generation is harmless.
func (*Tracker) TryClaim ¶
TryClaim reserves the right to run the claim CAS for one step, reporting false when a sibling worker in this replica already holds a reservation for it (in either generation). On true the caller owns the reservation until it expires with the maps or is explicitly released via RelinquishClaim.