-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: enable selecting subset of services using rendezvous hashing #12862
Conversation
Ignorable nit: Should we split the number and the key into different params? And then require that both are set? |
7c9056b
to
56b93a7
Compare
56b93a7
to
0cf884b
Compare
0cf884b
to
0fe0b54
Compare
671193b
to
c3ba29c
Compare
This PR adds the 'choose' query parameter to the '/v1/service/<service>' endpoint. The value of 'choose' is in the form '<number>|<key>', number is the number of desired services and key is a value unique but consistent to the requester (e.g. allocID). Folks aren't really expected to use this API directly, but rather through consul-template which will soon be getting a new helper function making use of this query parameter. Example, curl 'localhost:4646/v1/service/redis?choose=2|abc123' Note: consul-templte v0.29.1 includes the necessary nomadServices functionality.
c3ba29c
to
bdead31
Compare
Will add e2e test + complete example in the docs in a followup PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this will be really useful! Minor inline question, but as mentioned, I feel I know the answer already.
if err != nil { | ||
return nil, structs.ErrMalformedChooseParameter | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I already know the answer to this, but would it be worth logging the error content for cluster operators so this is available somewhere to lookup alongside the generic error return message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the only intended user is template/consul-template which will always be correct, though I could see the benefit for someone writing their own API client. If we do start logging RPC failures though we should probably do it at all the err points for consistency
Co-authored-by: James Rasell <jrasell@users.noreply.github.com>
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
This PR adds the
?choose
query parameter to the/v1/service/<service>
endpoint.The value of
choose
is in the form<number>|<key>
, number is the numberof desired services and key is a value unique but consistent to the requester
(e.g.
allocID
).Folks aren't really expected to use this API directly, but rather through
consul-template
/template
blockwhich will soon be getting a new helper function making use of this query parameter.
Example,
curl 'localhost:4646/v1/service/redis?choose=2|abc123'
Part of #12575
Because this also includes updating CT, the
template
part works now as well.