open-consul/command/agent/coordinate_endpoint.go

33 lines
1006 B
Go
Raw Normal View History

package agent
import (
"github.com/hashicorp/consul/consul/structs"
"net/http"
)
// CoordinateDatacenters returns the WAN nodes in each datacenter, along with
// raw network coordinates.
func (s *HTTPServer) CoordinateDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
var out []structs.DatacenterMap
if err := s.agent.RPC("Coordinate.ListDatacenters", struct{}{}, &out); err != nil {
return nil, err
}
return out, nil
}
// CoordinateNodes returns the LAN nodes in the given datacenter, along with
// raw network coordinates.
func (s *HTTPServer) CoordinateNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
args := structs.DCSpecificRequest{}
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
return nil, nil
}
var out structs.IndexedCoordinates
defer setMeta(resp, &out.QueryMeta)
if err := s.agent.RPC("Coordinate.ListNodes", &args, &out); err != nil {
return nil, err
}
return out.Coordinates, nil
}