Skip to content

Commit

Permalink
feat(php): waitForTasks param for various SearchClient methods (gener…
Browse files Browse the repository at this point in the history
…ated)

algolia/api-clients-automation#3565

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Aykut Ersoy <[email protected]>
  • Loading branch information
algolia-bot and aykutersoy committed Aug 20, 2024
1 parent 73a2545 commit ebf4927
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/Api/SearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2956,10 +2956,11 @@ public function replaceAllObjects($indexName, $objects, $batchSize = 1000, $requ
* @param string $indexName the `indexName` to replace `objects` in
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
* @param array $requestOptions Request options
* @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
*/
public function saveObjects($indexName, $objects, $requestOptions = [])
public function saveObjects($indexName, $objects, $requestOptions = [], $waitForTasks = false)
{
return $this->chunkedBatch($indexName, $objects, 'addObject', false, 1000, $requestOptions);
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, 1000, $requestOptions);
}

/**
Expand All @@ -2968,16 +2969,17 @@ public function saveObjects($indexName, $objects, $requestOptions = [])
* @param string $indexName the `indexName` to delete `objectIDs` from
* @param array $objectIDs the `objectIDs` to delete
* @param array $requestOptions Request options
* @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
*/
public function deleteObjects($indexName, $objectIDs, $requestOptions = [])
public function deleteObjects($indexName, $objectIDs, $requestOptions = [], $waitForTasks = false)
{
$objects = [];

foreach ($objectIDs as $id) {
$objects[] = ['objectID' => $id];
}

return $this->chunkedBatch($indexName, $objects, 'deleteObject', false, 1000, $requestOptions);
return $this->chunkedBatch($indexName, $objects, 'deleteObject', $waitForTasks, 1000, $requestOptions);
}

/**
Expand All @@ -2987,10 +2989,11 @@ public function deleteObjects($indexName, $objectIDs, $requestOptions = [])
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
* @param bool $createIfNotExists To be provided if non-existing objects are passed, otherwise, the call will fail..
* @param array $requestOptions Request options
* @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
*/
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [])
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [], $waitForTasks = false)
{
return $this->chunkedBatch($indexName, $objects, (true == $createIfNotExists) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', false, 1000, $requestOptions);
return $this->chunkedBatch($indexName, $objects, (true == $createIfNotExists) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, 1000, $requestOptions);
}

/**
Expand All @@ -2999,7 +3002,7 @@ public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $
* @param string $indexName the `indexName` to replace `objects` in
* @param array $objects the array of `objects` to store in the given Algolia `indexName`
* @param array $action the `batch` `action` to perform on the given array of `objects`, defaults to `addObject`
* @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
* @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
* @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.
* @param array $requestOptions Request options
*/
Expand Down

0 comments on commit ebf4927

Please sign in to comment.