2015-04-20 19:04:13 +00:00
|
|
|
package api
|
|
|
|
|
2018-07-24 22:49:55 +00:00
|
|
|
import "context"
|
|
|
|
|
2015-04-20 19:04:13 +00:00
|
|
|
func (c *Sys) Leader() (*LeaderResponse, error) {
|
|
|
|
r := c.c.NewRequest("GET", "/v1/sys/leader")
|
2018-07-24 22:49:55 +00:00
|
|
|
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
|
|
defer cancelFunc()
|
|
|
|
resp, err := c.c.RawRequestWithContext(ctx, r)
|
2015-04-20 19:04:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result LeaderResponse
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
type LeaderResponse struct {
|
2017-07-31 22:25:27 +00:00
|
|
|
HAEnabled bool `json:"ha_enabled"`
|
|
|
|
IsSelf bool `json:"is_self"`
|
|
|
|
LeaderAddress string `json:"leader_address"`
|
|
|
|
LeaderClusterAddress string `json:"leader_cluster_address"`
|
2015-04-20 19:04:13 +00:00
|
|
|
}
|