Skip to content

Commit

Permalink
refactor: renames sort function to avoid "remove" verb
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Oct 8, 2024
1 parent 6d716e4 commit 4f01d40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion state/applicationoffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (op *RemoveOfferOperation) Build(attempt int) (ops []txn.Op, err error) {
ops = append(ops, proxyOps...)
}

sortRemoveOpsLast(ops)
sortRemovalOpsLast(ops)
return ops, nil
}

Expand Down
6 changes: 3 additions & 3 deletions state/modeloperation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package state

import (
"sort"

"github.com/juju/errors"
"github.com/juju/mgo/v3/txn"
jujutxn "github.com/juju/txn/v3"
Expand Down Expand Up @@ -107,7 +107,7 @@ func (st *State) ApplyOperation(op ModelOperation) error {
return op.Done(err)
}

// sortRemoveOpsLast re-orders a slice of transaction operations so that any
// sortRemovalOpsLast re-orders a slice of transaction operations so that any
// document removals occur at the end of the slice.
// This is important for server-side transactions because of two execution
// characteristics:
Expand All @@ -117,7 +117,7 @@ func (st *State) ApplyOperation(op ModelOperation) error {
// on the same document to pass the assertions, then fail with "not found" upon
// actual processing.
// Legacy client-side transactions do not exhibit this behaviour.
func sortRemoveOpsLast(ops []txn.Op) {
func sortRemovalOpsLast(ops []txn.Op) {
sort.Slice(ops, func(i, j int) bool {
return !ops[i].Remove && ops[j].Remove
})
Expand Down
2 changes: 1 addition & 1 deletion state/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (op *DestroyRelationOperation) internalDestroy() (ops []txn.Op, err error)
}

ops = append(ops, destroyOps...)
sortRemoveOpsLast(ops)
sortRemovalOpsLast(ops)
return ops, nil
}

Expand Down

0 comments on commit 4f01d40

Please sign in to comment.