Changes ?near=self to a safer ?near=_agent, which is also clearer about what it does.

This commit is contained in:
James Phillips 2015-07-28 10:39:37 -07:00
parent 9caa5b3653
commit 9c9195746f
4 changed files with 8 additions and 8 deletions

View File

@ -491,7 +491,7 @@ func (s *HTTPServer) parseToken(req *http.Request, token *string) {
func (s *HTTPServer) parseSource(req *http.Request, source *structs.QuerySource) {
s.parseDC(req, &source.Datacenter)
if node := req.URL.Query().Get("near"); node != "" {
if node == "self" {
if node == "_agent" {
source.Node = s.agent.config.NodeName
} else {
source.Node = node

View File

@ -381,9 +381,9 @@ func TestParseSource(t *testing.T) {
t.Fatalf("bad: %v", source)
}
// The magic "self" node name will use the agent's local node name.
// The magic "_agent" node name will use the agent's local node name.
req, err = http.NewRequest("GET",
"/v1/catalog/nodes?near=self", nil)
"/v1/catalog/nodes?near=_agent", nil)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -181,7 +181,7 @@ however, the dc can be provided using the "?dc=" query parameter.
Adding the optional "?near=" parameter with a node name will sort
the node list in ascending order based on the estimated round trip
time from that node. Passing "?near=self" will use the agent's local
time from that node. Passing "?near=_agent" will use the agent's
node for the sort.
It returns a JSON body like this:
@ -237,7 +237,7 @@ by tag using the "?tag=" query parameter.
Adding the optional "?near=" parameter with a node name will sort
the node list in ascending order based on the estimated round trip
time from that node. Passing "?near=self" will use the agent's local
time from that node. Passing "?near=_agent" will use the agent's
node for the sort.
It returns a JSON body like this:

View File

@ -72,7 +72,7 @@ however, the dc can be provided using the "?dc=" query parameter.
Adding the optional "?near=" parameter with a node name will sort
the node list in ascending order based on the estimated round trip
time from that node. Passing "?near=self" will use the agent's local
time from that node. Passing "?near=_agent" will use the agent's
node for the sort.
It returns a JSON body like this:
@ -102,7 +102,7 @@ however, the dc can be provided using the "?dc=" query parameter.
Adding the optional "?near=" parameter with a node name will sort
the node list in ascending order based on the estimated round trip
time from that node. Passing "?near=self" will use the agent's local
time from that node. Passing "?near=_agent" will use the agent's
node for the sort.
By default, all nodes matching the service are returned. The list can be filtered
@ -171,7 +171,7 @@ however, the dc can be provided using the "?dc=" query parameter.
Adding the optional "?near=" parameter with a node name will sort
the node list in ascending order based on the estimated round trip
time from that node. Passing "?near=self" will use the agent's local
time from that node. Passing "?near=_agent" will use the agent's
node for the sort.
The supported states are `any`, `unknown`, `passing`, `warning`, or `critical`.