projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
7709: Merge branch 'master' into 7709-api-rails4
[arvados.git]
/
sdk
/
go
/
keepclient
/
root_sorter.go
diff --git
a/sdk/go/keepclient/root_sorter.go
b/sdk/go/keepclient/root_sorter.go
index 7a73d957a0e9ed4bcaf1f37c7b7ec224f1ac6bfc..a8afea096109531ad0e27bf4c31e5b26010c8538 100644
(file)
--- a/
sdk/go/keepclient/root_sorter.go
+++ b/
sdk/go/keepclient/root_sorter.go
@@
-1,18
+1,16
@@
package keepclient
import (
package keepclient
import (
- "crypto/md5"
- "fmt"
"sort"
)
type RootSorter struct {
"sort"
)
type RootSorter struct {
- root
[]string
- weight
[]string
- order
[]int
+ root []string
+ weight []string
+ order []int
}
}
-func NewRootSorter(serviceRoots map[string]string, hash string)
(*RootSorter)
{
+func NewRootSorter(serviceRoots map[string]string, hash string)
*RootSorter
{
rs := new(RootSorter)
rs.root = make([]string, len(serviceRoots))
rs.weight = make([]string, len(serviceRoots))
rs := new(RootSorter)
rs.root = make([]string, len(serviceRoots))
rs.weight = make([]string, len(serviceRoots))
@@
-28,18
+26,16
@@
func NewRootSorter(serviceRoots map[string]string, hash string) (*RootSorter) {
return rs
}
return rs
}
-func (rs RootSorter) getWeight(hash string, uuid string) (string) {
- var service_key []byte
+func (rs RootSorter) getWeight(hash string, uuid string) string {
if len(uuid) == 27 {
if len(uuid) == 27 {
-
service_key = []byte
(hash + uuid[12:])
+
return Md5String
(hash + uuid[12:])
} else {
// Only useful for testing, a set of one service root, etc.
} else {
// Only useful for testing, a set of one service root, etc.
-
service_key = []byte
(hash + uuid)
+
return Md5String
(hash + uuid)
}
}
- return fmt.Sprintf("%x", md5.Sum(service_key))
}
}
-func (rs RootSorter) GetSortedRoots()
([]string)
{
+func (rs RootSorter) GetSortedRoots()
[]string
{
sorted := make([]string, len(rs.order))
for i := range rs.order {
sorted[i] = rs.root[rs.order[i]]
sorted := make([]string, len(rs.order))
for i := range rs.order {
sorted[i] = rs.root[rs.order[i]]