-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add Coordinate endpoint #67
Conversation
Hi Maxim, thank you for the PR! See my comments below.
Vector is fine
Yeah, I don't like exception here either. If I need to design Ppconsul this days then I would return an empty optional but it's already designed and to keep consistency with other APIs let's return an empty vector.
Adding coordinates to |
And one more thing. Several endpoints support a special value |
return std::none_of( | ||
nodes.begin(), nodes.end(), | ||
[dim](const auto& node) | ||
{ | ||
return (node.coord.vec.size() != dim); | ||
} | ||
); |
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.
To remove the double negation (it's hard to understand) use std::all_of
with "positive" predicate.
If you need to see hot to handle status code without exceptions check |
This PR implements coordinate endpoint queries:
/coordinate/datacenters
/coordinate/nodes
/coordinate/node/:node
It doesn't add an implementation for
/coordinate/update
./coordinate/node/:node
Returning
std::vector
I don't quite like returning a vector of nodes in
/coordinate/node/:node
, but the endpoint returns an array for this request (see Sample Response)I'm not sure how
ppconsul
handles Enterprise features. It's not required in my use-case so it's up to you.Should we leave it like that (i.e. return a vector)?
NotFoundError handling
Currently
/coordinate/node/:node
throwsNotFoundError
if node does not exist (because of the API responding with 404).Should we catch it and return empty vector instead?
/agent/self
This request also returns Coordinate block, should we implement it aswell?
Although it seems to be difficult without breaking existing interface. Maybe by adding coordinates to
Member
struct?