import (
"crypto/tls"
"encoding/json"
+ "fmt"
"net/http"
+ "sort"
)
type KeepDisk struct {
Hostname string `json:"service_host"`
Port int `json:"service_port"`
+ SSL bool `json:"service_ssl_flag"`
}
-func KeepDisks() (disks []KeepDisk, err error) {
+func KeepDisks() (service_roots []string, err error) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
return nil, err
}
- return m.Items, nil
+ service_roots = make([]string, len(m.Items))
+ for index, element := range m.Items {
+ n := ""
+ if element.SSL {
+ n = "s"
+ }
+ service_roots[index] = fmt.Sprintf("http%s://%s:%d",
+ n, element.Hostname, element.Port)
+ }
+ sort.Strings(service_roots)
+ return service_roots, nil
+}
+
+/*
+func ProbeSequence(service_roots []string) (pseq []string) {
+ pseq = make([]string, 0, len(disks))
+ pool := disks[:]
+
}
+*/
var _ = Suite(&MySuite{})
func (s *MySuite) TestGetKeepDisks(c *C) {
- k, err := KeepDisks()
+ sr, err := KeepDisks()
c.Assert(err, Equals, nil)
- c.Assert(len(k), Equals, 2)
- c.Assert(k[0].Hostname, Equals, "localhost")
- c.Assert(k[0].Port, Equals, 25108)
- c.Assert(k[1].Hostname, Equals, "localhost")
- c.Assert(k[1].Port, Equals, 25107)
+ c.Assert(len(sr), Equals, 2)
+ c.Assert(sr[0], Equals, "http://localhost:25107")
+ c.Assert(sr[1], Equals, "http://localhost:25108")
+
}