Skip to content

feat(php): waitForTasks param for various SearchClient methods #3565

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

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
19 changes: 11 additions & 8 deletions templates/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,10 @@ use {{invokerPackage}}\Support\Helpers;
* @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 = []) {
return $this->chunkedBatch($indexName, $objects, 'addObject', false, 1000, $requestOptions);
public function saveObjects($indexName, $objects, $requestOptions = [], $waitForTasks = false) {
return $this->chunkedBatch($indexName, $objects, 'addObject', $waitForTasks, 1000, $requestOptions);
}

/**
Expand All @@ -514,16 +515,17 @@ use {{invokerPackage}}\Support\Helpers;
* @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 @@ -532,10 +534,11 @@ use {{invokerPackage}}\Support\Helpers;
* @param string $indexName The `indexName` to replace `objects` in.
* @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 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 = []) {
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', false, 1000, $requestOptions);
public function partialUpdateObjects($indexName, $objects, $createIfNotExists, $requestOptions = [], $waitForTasks = false) {
return $this->chunkedBatch($indexName, $objects, ($createIfNotExists == TRUE) ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', $waitForTasks, 1000, $requestOptions);
}

/**
Expand All @@ -544,7 +547,7 @@ use {{invokerPackage}}\Support\Helpers;
* @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
Loading