1
0
Fork 0

Better comments

master
Philip O'Toole 7 months ago
parent 1237481f53
commit 5722424880

@ -27,17 +27,24 @@ func IsStaleRead(
strict bool,
) bool {
if freshness == 0 {
// Freshness not set, so no read can be stale.
return false
}
if time.Since(leaderlastContact).Nanoseconds() > freshness {
// The Leader has not been in contact witin the freshness window, so
// the read is stale.
return true
}
if !strict {
// Strict mode is not enabled, so no further checks are needed.
return false
}
if fsmIndex == commitIndex {
// FSM index is the same as the commit index, so we're caught up.
return false
}
// OK, we're not caught up. So was the log that last updated our local FSM
// appended by the Leader to its log within the freshness window?
return lastFSMUpdateTime.Sub(lastAppendedAtTime).Nanoseconds() > freshness
}

Loading…
Cancel
Save