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

Add "Async" to the end of each Async RestClient method #20172

Merged
merged 1 commit into from
Aug 26, 2016

Conversation

pickypg
Copy link
Member

@pickypg pickypg commented Aug 25, 2016

This makes it much harder to accidentally miss the Response.

Closes #20168

@pickypg pickypg added >enhancement :Clients/Java Low Level REST Client Minimal dependencies Java Client for Elasticsearch v5.0.0-beta1 review labels Aug 25, 2016
@@ -98,7 +98,7 @@ protected void doStart(Consumer<? super Response> onResponse) {

void lookupRemoteVersion(Consumer<Version> onVersion) {
execute("GET", "", emptyMap(), null, MAIN_ACTION_PARSER, onVersion);

Copy link
Member

Choose a reason for hiding this comment

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

This line can just be removed

@tlrx
Copy link
Member

tlrx commented Aug 26, 2016

LGTM, left minor comment

This makes it much harder to accidentally miss the Response.
@pickypg pickypg force-pushed the feature/add-async-for-async-calls branch from 646b69b to bd0b064 Compare August 26, 2016 14:51
@pickypg pickypg merged commit bd0b064 into elastic:master Aug 26, 2016
@pickypg pickypg deleted the feature/add-async-for-async-calls branch August 26, 2016 14:58
@javanna
Copy link
Member

javanna commented Aug 29, 2016

@pickypg can you elaborate on how one could miss the response? ResponseListener is a required argument. it's not that we return a future and people can forget to call get against it here...

I think we need to update the docs as well: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_performing_requests.html

@pickypg
Copy link
Member Author

pickypg commented Aug 29, 2016

it's not that we return a future and people can forget to call get against it here...

Thankfully! It's really just to avoid the confusion. I've used both the sync and async methods in my own code now, and I had to baby-step out the parameters to ensure that I was calling the right one. On the bright side, you also did a good job by making the synchronous variants throw an IOException (the async doesn't for anyone reading), but that was only obvious after looking through it all.

A synchronous and asynchronous API only differing by parameters is still trappy in my book, particularly if you're unfamiliar with what's happening. I agree that any experienced user wouldn't make these mistakes (in fact, you can't), but those 5 letters go a long way to help guide the end user.

@pickypg
Copy link
Member Author

pickypg commented Aug 29, 2016

I think we need to update the docs as well

Good catch. I'll submit a separate PR for that.

@pickypg pickypg removed the review label Aug 29, 2016
@javanna
Copy link
Member

javanna commented Aug 29, 2016

fair enough, thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Clients/Java Low Level REST Client Minimal dependencies Java Client for Elasticsearch >enhancement v5.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants