forked from ContainX/depcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
45 lines (37 loc) · 1011 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package marathon
import "net/url"
func (c *MarathonClient) GetMarathonInfo() (*MarathonInfo, error) {
info := new(MarathonInfo)
resp := c.http.HttpGet(c.marathonUrl(API_INFO), info)
if resp.Error != nil {
return nil, resp.Error
}
return info, nil
}
func (c *MarathonClient) GetCurrentLeader() (*LeaderInfo, error) {
info := new(LeaderInfo)
resp := c.http.HttpGet(c.marathonUrl(API_LEADER), info)
if resp.Error != nil {
return nil, resp.Error
}
return info, nil
}
func (c *MarathonClient) AbdicateLeader() (*Message, error) {
msg := new(Message)
resp := c.http.HttpDelete(c.marathonUrl(API_LEADER), nil, msg)
if resp.Error != nil {
return nil, resp.Error
}
return msg, nil
}
func (c *MarathonClient) Ping() (*MarathonPing, error) {
resp := c.http.HttpGet(c.marathonUrl(API_PING), nil)
if resp.Error != nil {
return nil, resp.Error
}
host := c.host
if u, err := url.Parse(c.host); err == nil {
host = u.Host
}
return &MarathonPing{Host: host, Elapsed: resp.Elapsed}, nil
}