-
Notifications
You must be signed in to change notification settings - Fork 32
/
common.go
69 lines (62 loc) · 1.73 KB
/
common.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package druid
const (
StatusEndpoint = "status"
HealthEndpoint = "status/health"
PropertiesEndpoint = "status/properties"
SelfDiscoveredEndpoint = "status/selfDiscovered/status"
)
type Status struct {
Version string `json:"version"`
Modules []struct {
Name string `json:"name"`
Artifact string `json:"artifact"`
Version string `json:"version"`
} `json:"modules"`
Memory struct {
MaxMemory int `json:"maxMemory"`
TotalMemory int `json:"totalMemory"`
FreeMemory int `json:"freeMemory"`
UsedMemory int `json:"usedMemory"`
DirectMemory int `json:"directMemory"`
} `json:"memory"`
}
type Health bool
type Properties map[string]string
type SelfDiscovered struct {
SelfDiscovered bool `json:"selfDiscovered"`
}
type CommonService struct {
client *Client
}
func (c *CommonService) Status() (*Status, *Response, error) {
var s *Status
response, err := c.client.ExecuteRequest("GET", StatusEndpoint, nil, &s)
if err != nil {
return nil, response, err
}
return s, response, nil
}
func (c *CommonService) Health() (*Health, *Response, error) {
var h *Health
response, err := c.client.ExecuteRequest("GET", HealthEndpoint, nil, &h)
if err != nil {
return nil, response, err
}
return h, response, nil
}
func (c *CommonService) Properties() (*Properties, *Response, error) {
var p *Properties
response, err := c.client.ExecuteRequest("GET", PropertiesEndpoint, nil, &p)
if err != nil {
return nil, response, err
}
return p, response, nil
}
func (c *CommonService) SelfDiscovered() (*SelfDiscovered, *Response, error) {
var s *SelfDiscovered
response, err := c.client.ExecuteRequest("GET", SelfDiscoveredEndpoint, nil, &s)
if err != nil {
return nil, response, err
}
return s, response, nil
}