api: Use blocking query for health when near is set

Streaming can not be used for these queries because the near query
paramter indicates a specific sort of the results, and that sort
requires data that is not available to the client from the streaming
API.
This commit is contained in:
Daniel Nephin 2021-02-09 13:55:26 -05:00
parent 5b54842e44
commit 041f96639d
1 changed files with 4 additions and 1 deletions

View File

@ -219,7 +219,10 @@ func (s *HTTPHandlers) healthServiceNodes(resp http.ResponseWriter, req *http.Re
return nil, nil return nil, nil
} }
useStreaming := s.agent.config.UseStreamingBackend && args.MinQueryIndex > 0 // useStreaming when a blocking query is requested, but not when the near
// query parameter is set, because that requires data only available to the server
// to sort the results.
useStreaming := s.agent.config.UseStreamingBackend && args.MinQueryIndex > 0 && args.Source.Node == ""
args.QueryOptions.UseCache = s.agent.config.HTTPUseCache && (args.QueryOptions.UseCache || useStreaming) args.QueryOptions.UseCache = s.agent.config.HTTPUseCache && (args.QueryOptions.UseCache || useStreaming)
out, md, err := s.agent.rpcClientHealth.ServiceNodes(req.Context(), args) out, md, err := s.agent.rpcClientHealth.ServiceNodes(req.Context(), args)