Skip to content

Add documentation for BatchClient, BatchResult and BatchException #20

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

Merged
merged 1 commit into from
Oct 31, 2015

Conversation

thormeier
Copy link
Contributor

Solves #16


## BatchClient

This client wraps the HttpClient and extends it with the possibility to send an array of requests and to retrieve their responses as a `BatchResult`.
Copy link
Member

Choose a reason for hiding this comment

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

wraps a HttpClient

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed :)

@joelwurtz
Copy link
Member

Awesome <3 ! 👍


$batchResult = $client->sendRequests($requests);

if ($batchResult->hasResponses() && !$batchResult->hasExceptions()) {
Copy link
Member

Choose a reason for hiding this comment

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

Does the exception check make sense here? Exception is thrown if any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Removed it.

@sagikazarmark
Copy link
Member

Added one comment. Please squash commits.

Thanks @thormeier

@thormeier
Copy link
Contributor Author

Fixed mentioned things and squashed commits.

@sagikazarmark
Copy link
Member

Thanks @thormeier

sagikazarmark added a commit that referenced this pull request Oct 31, 2015
Add documentation for BatchClient, BatchResult and BatchException
@sagikazarmark sagikazarmark merged commit f1b2b86 into php-http:master Oct 31, 2015

if ($batchResult->hasResponses()) {
$fooSuccessful = $batchResult->isSuccesful($requests[0]);
$updateResponse = $batchResult->getResponseFor($request[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is assuming that the post request did not fail and would throw an exception if it failed. in this flow of code, that can't happen as we would have bailed out with an exception. but that means $fooSuccessful is pointless. i would move the isSuccessful check below to the error handling logic, as its only relevant in the error case to figure out if something went wrong or not.

Copy link
Member

Choose a reason for hiding this comment

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

Wow, my breain blown up while following this reasoning (guess it's sunday evening), so I just agree with you. 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, sunday evening here as well :-D i think in the middle i realized that we can just expect the response to be there in this case... but we should separate the examples to make it more clear. we could even mention that we can just assume responses are here as otherwise there would be the exception thrown.

@dbu
Copy link
Contributor

dbu commented Nov 1, 2015

thanks a lot for the contribution! i commented some details, if you find some time to clean this up, great, but at least we have some documentation now.

@dbu dbu mentioned this pull request Nov 3, 2015
@ddeboer ddeboer mentioned this pull request Jan 6, 2016
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants