Skip to content
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

ui: HTTPAdapter queryLeader refactor #6386

Merged

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Aug 23, 2019

As the HTTPAdapter work (see #5637) has been long running, we've since added functionality to figure out the leader of the consul datacenter, which uses the status API (see #6265).

This PR migrates this work over to the new HTTPAdapter, we also add a couple of extra tests here.

The related changes commit also happen elsewhere, and are 'incidental' changes to pretty much tie up all the loose ends of this run of work whilst keeping the ember upgrade as a separate PR.

As a side note: You can really see the difference in this diff in complication with adding a new API call here between the old way and the new way 🎉

@johncowen johncowen requested a review from a team August 23, 2019 16:15
@johncowen johncowen added the theme/ui Anything related to the UI label Aug 23, 2019
Copy link

@backspace backspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it cleans things up nicely! I left a couple of small comments, I’m not familiar enough to say these are requirements, but at least things to consider.

return adapter.requestForQueryLeader(request, serialized, unserialized);
},
function(serializer, response, serialized, unserialized) {
return serializer.respondForQueryLeader(response, serialized, unserialized);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a bit confusing to me that this is called respondFor… but a response is passed in. The actual function definition calls it respond instead. Maybe it should be responseForQueryLeader, as it seems to me that it’s generating a response, not actually responding? But maybe I’m way off hehe

Also, the function doesn’t look like it uses the third parameter, is there a reason to include it in this call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm yeah, thinking back I wanted it to match up with requestFor..., but I suppose I was thinking of it as a verb rather than a noun - I kinda tried to make this look like the old urlFor... things which uses nouns, so maybe these should be thought of as nouns also as you suggest here. Let me take another look at it, the reasons why (if there were any) might have got lost in the refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not looked in detail yet buck, but just realized something else here which might be more 'correct' sounding. request and response are actually functions, that when called 'do' the request things, or the response things. So I'm considering the option of changing the name of the argument to respond here. As its a function, a verb usually fits better. Just wanted to P.S. that on here, I'm gonna take a closer look now.

Copy link
Contributor Author

@johncowen johncowen Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, so, I went with changing the arg to be called respond, which as its a function looks more 'function-y' - lemme know what you think.

Also, the function doesn’t look like it uses the third parameter, is there a reason to include it in this call?

I generally keep unused arguments in there, mainly for basic documentation (somebody else might come along and see they have unserialized at their disposal within the function's scope even though it wasn't used previously) and for consistency.

Unused arguments will get uglified out in the build also

// This response is just an ip:port like `"10.0.0.1:8000"`
// split it and make it look like a `C`onsul.`R`esponse
// popping off the end for ports should cover us for IPv6 addresses
// as we should always get a `address:port` or `[a:dd:re:ss]:port` combo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be helpful to show example input and output here? I see the output but I’m not sure what input it’s operating on.

Copy link
Contributor Author

@johncowen johncowen Aug 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just incase, [Outdated] doesn't show in the GH ui in certain places as a code comment has been added for this a few lines under here to address this comment.

@johncowen johncowen requested a review from backspace August 28, 2019 16:06
@johncowen johncowen force-pushed the feature/ui-http-adapter-query-leader branch from df63c7d to 875e839 Compare August 29, 2019 11:00
@johncowen johncowen mentioned this pull request Aug 29, 2019
John Cowen added 2 commits August 29, 2019 11:37
store.queryLeader now appears twice after that merge, we remove the
duplicate here
These values are generally merged together, and consul-api-double now has 2
meta values for services. Add another additional meta value here for
testing/mocking purposes.
@johncowen
Copy link
Contributor Author

I've added a couple of commits on the end of here that were required as a result of merging and rebasing this to pull it up to date with master/ui-staging, this PR seemed to be a better place to add them.

@johncowen johncowen merged commit 961ef12 into feature/ui-http-adapter Aug 29, 2019
@johncowen johncowen deleted the feature/ui-http-adapter-query-leader branch August 29, 2019 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants