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

Attempt to retry valid calls when it is possible to resume #1220

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Spanner/src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ public function rows($format = self::RETURN_ASSOCIATIVE)
$call = $this->call;
$generator = $call();
$shouldRetry = false;
$valid = $generator->valid();

while ($generator->valid()) {
while ($valid) {
try {
$result = $generator->current();
$bufferedResults[] = $result;
Expand Down Expand Up @@ -205,12 +206,11 @@ public function rows($format = self::RETURN_ASSOCIATIVE)
}

$generator->next();
$valid = $generator->valid();
} catch (ServiceException $ex) {
if ($shouldRetry && $ex->getCode() === Grpc\STATUS_UNAVAILABLE) {
$backoff = new ExponentialBackoff($this->retries, function (ServiceException $ex) {
return $ex->getCode() === Grpc\STATUS_UNAVAILABLE
? true
: false;
return $ex->getCode() === Grpc\STATUS_UNAVAILABLE;
});

// Attempt to resume using our last stored resume token. If we
Expand Down