-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: fix revive linter #16634
*: fix revive linter #16634
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,12 +96,11 @@ func (s EtcdState) Step(request EtcdRequest) (EtcdState, MaybeEtcdResponse) { | |
if request.Range.Revision == 0 || request.Range.Revision == s.Revision { | ||
resp := s.getRange(request.Range.RangeOptions) | ||
return s, MaybeEtcdResponse{EtcdResponse: EtcdResponse{Range: &resp, Revision: s.Revision}} | ||
} else { | ||
if request.Range.Revision > s.Revision { | ||
return s, MaybeEtcdResponse{Error: EtcdFutureRevErr.Error()} | ||
} | ||
return s, MaybeEtcdResponse{PartialResponse: true, EtcdResponse: EtcdResponse{Revision: s.Revision}} | ||
} | ||
if request.Range.Revision > s.Revision { | ||
return s, MaybeEtcdResponse{Error: ErrEtcdFutureRev.Error()} | ||
} | ||
return s, MaybeEtcdResponse{PartialResponse: true, EtcdResponse: EtcdResponse{Revision: s.Revision}} | ||
case Txn: | ||
failure := false | ||
for _, cond := range request.Txn.Conditions { | ||
|
@@ -148,7 +147,7 @@ func (s EtcdState) Step(request EtcdRequest) (EtcdState, MaybeEtcdResponse) { | |
} | ||
} | ||
if increaseRevision { | ||
s.Revision += 1 | ||
s.Revision++ | ||
} | ||
return s, MaybeEtcdResponse{EtcdResponse: EtcdResponse{Txn: &TxnResponse{Failure: failure, Results: opResp}, Revision: s.Revision}} | ||
case LeaseGrant: | ||
|
@@ -174,7 +173,7 @@ func (s EtcdState) Step(request EtcdRequest) (EtcdState, MaybeEtcdResponse) { | |
//delete the lease | ||
delete(s.Leases, request.LeaseRevoke.LeaseID) | ||
if keyDeleted { | ||
s.Revision += 1 | ||
s.Revision++ | ||
} | ||
return s, MaybeEtcdResponse{EtcdResponse: EtcdResponse{Revision: s.Revision, LeaseRevoke: &LeaseRevokeResponse{}}} | ||
case Defragment: | ||
|
@@ -193,7 +192,7 @@ func (s EtcdState) getRange(options RangeOptions) RangeResponse { | |
for k, v := range s.KeyValues { | ||
if k >= options.Start && k < options.End { | ||
response.KVs = append(response.KVs, KeyValue{Key: k, ValueRevision: v}) | ||
count += 1 | ||
count++ | ||
} | ||
} | ||
sort.Slice(response.KVs, func(j, k int) bool { | ||
|
@@ -315,7 +314,7 @@ type MaybeEtcdResponse struct { | |
Error string | ||
} | ||
|
||
var EtcdFutureRevErr = errors.New("future rev") | ||
var ErrEtcdFutureRev = errors.New("future rev") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did revive linter raise a warning on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. The error is here
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx for the clarification. |
||
|
||
type EtcdResponse struct { | ||
Txn *TxnResponse | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did revive linter raise a warning on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx