-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
|
||
## 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`. |
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.
wraps a HttpClient
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.
Fixed :)
Awesome <3 ! 👍 |
|
||
$batchResult = $client->sendRequests($requests); | ||
|
||
if ($batchResult->hasResponses() && !$batchResult->hasExceptions()) { |
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.
Does the exception check make sense here? Exception is thrown if any.
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.
True. Removed it.
Added one comment. Please squash commits. Thanks @thormeier |
884c455
to
35bff47
Compare
Fixed mentioned things and squashed commits. |
Thanks @thormeier |
Add documentation for BatchClient, BatchResult and BatchException
|
||
if ($batchResult->hasResponses()) { | ||
$fooSuccessful = $batchResult->isSuccesful($requests[0]); | ||
$updateResponse = $batchResult->getResponseFor($request[1]); |
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.
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.
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.
Wow, my breain blown up while following this reasoning (guess it's sunday evening), so I just agree with you. 😉
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.
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.
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. |
Solves #16