Skip to content

Commit d0e4f4e

Browse files
authored
feat(php): waitForTasks param for various SearchClient methods (#3565)
1 parent 4c02596 commit d0e4f4e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

templates/php/api.mustache

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,10 @@ use {{invokerPackage}}\Support\Helpers;
503503
* @param string $indexName The `indexName` to replace `objects` in.
504504
* @param array $objects The array of `objects` to store in the given Algolia `indexName`.
505505
* @param array $requestOptions Request options
506+
* @param bool $waitForTasks Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
506507
*/
507-
public function saveObjects($indexName, $objects, $requestOptions = []) {
508-
return $this->chunkedBatch($indexName, $objects, 'addObject', false, 1000, $requestOptions);
508+
public function saveObjects($indexName, $objects, $requestOptions = [], $waitForTasks = false) {
509+
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, 1000, $requestOptions);
509510
}
510511

511512
/**
@@ -514,16 +515,17 @@ use {{invokerPackage}}\Support\Helpers;
514515
* @param string $indexName The `indexName` to delete `objectIDs` from.
515516
* @param array $objectIDs The `objectIDs` to delete.
516517
* @param array $requestOptions Request options
518+
* @param bool $waitForTasks Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
517519
*/
518-
public function deleteObjects($indexName, $objectIDs, $requestOptions = [])
520+
public function deleteObjects($indexName, $objectIDs, $requestOptions = [], $waitForTasks = false)
519521
{
520522
$objects = [];
521523
522524
foreach ($objectIDs as $id) {
523525
$objects[] = ['objectID' => $id];
524526
}
525527

526-
return $this->chunkedBatch($indexName, $objects, 'deleteObject', false, 1000, $requestOptions);
528+
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, 1000, $requestOptions);
527529
}
528530

529531
/**
@@ -532,10 +534,11 @@ use {{invokerPackage}}\Support\Helpers;
532534
* @param string $indexName The `indexName` to replace `objects` in.
533535
* @param array $objects The array of `objects` to store in the given Algolia `indexName`.
534536
* @param bool $createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
535-
* @param array $requestOptions Request options
537+
* @param array $requestOptions Request options
538+
* @param bool $waitForTasks Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
536539
*/
537-
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = []) {
538-
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', false, 1000, $requestOptions);
540+
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [], $waitForTasks = false) {
541+
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, 1000, $requestOptions);
539542
}
540543

541544
/**
@@ -544,7 +547,7 @@ use {{invokerPackage}}\Support\Helpers;
544547
* @param string $indexName the `indexName` to replace `objects` in
545548
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
546549
* @param array $action the `batch` `action` to perform on the given array of `objects`, defaults to `addObject`
547-
* @param array $waitForTasks whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
550+
* @param bool $waitForTasks whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable
548551
* @param array $batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
549552
* @param array $requestOptions Request options
550553
*/

0 commit comments

Comments
 (0)