Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

Commit

Permalink
better comments around version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Skelcy committed Apr 23, 2018
1 parent b5982eb commit 55d6d71
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion service/r2/store/kv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,15 @@ func (s *store) UpdateRuleSet(
if err != nil {
return nil, handleUpstreamError(err)
}
// If ruleset version fetched from KV matches the change set version, the check and set operation will succeed if the underlying
// KV version remains the same before the change is committed and fail otherwise. If the fetched version doesn't
// match, we will fail fast.
if version != rs.Version() {
return nil, r2.NewConflictError("mismatched ruleset version number")
return nil, r2.NewConflictError(fmt.Sprintf(
"ruleset version mismatch: current version=%d, expected version=%d",
rs.Version(),
version,
))
}

mutable := rs.ToMutableRuleSet().Clone()
Expand Down

0 comments on commit 55d6d71

Please sign in to comment.