fixed typos

This commit is contained in:
ston1th 2020-06-10 01:25:17 +02:00
commit 349afa60e1

View file

@ -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