fixed typos
This commit is contained in:
parent
4158f7f946
commit
349afa60e1
1 changed files with 5 additions and 3 deletions
8
node.go
8
node.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -71,13 +72,14 @@ func (nl *NodeList) getServerList(ctx context.Context, c *NodeClient) (err error
|
|||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type weightSorter NodeList
|
||||
|
||||
func (s weightSorter) Len() int { return len(s) }
|
||||
func (s weightSorter) Less(i, j int) bool {
|
||||
return s.weight() < s[j].weight()
|
||||
return s[i].weight() < s[j].weight()
|
||||
}
|
||||
func (s weightSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
|
|
@ -107,7 +109,7 @@ func FilterNodeName(name string) NodeFilter {
|
|||
func FilterMaxCores(cores int64) NodeFilter {
|
||||
return func(nl *NodeList) {
|
||||
for i, n := range *nl {
|
||||
if cores > n.MaxCPU {
|
||||
if cores > int64(n.MaxCPU) {
|
||||
nl.remove(i)
|
||||
}
|
||||
}
|
||||
|
|
@ -170,7 +172,7 @@ func (c *NodeClient) Schedule(ctx context.Context, filters ...NodeFilter) (n *No
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
nl.filter(filters)
|
||||
nl.filter(filters...)
|
||||
nl.sortByWeight()
|
||||
if len(nl) == 0 {
|
||||
err = ErrUnschedulable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue