From 956361a9616457f93c96c3b22f742e9f5bce3d7c Mon Sep 17 00:00:00 2001 From: Vishwaraj Anand Date: Tue, 30 Aug 2022 07:28:55 +0000 Subject: [PATCH] fix: bulkwriter documentation errors --- Firestore/src/BulkWriter.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Firestore/src/BulkWriter.php b/Firestore/src/BulkWriter.php index d48d4f87b435..89d97f0ac810 100644 --- a/Firestore/src/BulkWriter.php +++ b/Firestore/src/BulkWriter.php @@ -659,11 +659,11 @@ public function flush($waitForRetryableFailures = false) /** * Reschedule failed mutations if retryable. * - * @param int $writesId Sequence of mutation among all enqueued writes. - * @param int $lastRunStatusCode + * @param int $writesId Sequence of mutation among all enqueued writes + * @param int $lastRunStatusCode Previous status code of batchWrite * @return void */ - private function handleSendbatchFailure(int $writesId, int $lastRunStatusCode) + private function handleSendbatchFailure($writesId, $lastRunStatusCode) { if ($lastRunStatusCode === Code::OK) { return; @@ -754,7 +754,14 @@ public function close() return $this->finalResponse; } - public function getBackoffDuration(int $lastStatus, $backoffDurationInMillis = 0) + /** + * Gets updated backoff duration provided last status code and backoff duration. + * + * @param int $lastStatus Previous status code of batchWrite + * @param int $backoffDurationInMillis Previous backoff duration in milliseconds + * @return int + */ + public function getBackoffDuration($lastStatus, $backoffDurationInMillis = 0) { if ($lastStatus === Code::RESOURCE_EXHAUSTED) { $backoffDurationInMillis = $this->maxDelayTime; @@ -1376,7 +1383,13 @@ private function checkWriterConditions($document) $this->unique_documents[] = $document; } - private function applyJitter(int $backoffMs) + /** + * Applies jitter to backoff duration. + * + * @param int $backoffMs The backoff duration in milliseconds. + * @return int Jittered backoff duration in milliseconds. + */ + private function applyJitter($backoffMs) { if ($backoffMs <= 0) { return 0;