Skip to content

Commit b263d48

Browse files
fix(clients): WithTransformation methods retry logic (generated)
algolia/api-clients-automation#5183 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent d8cb6de commit b263d48

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6760,6 +6760,25 @@ public <T> List<WatchResponse> saveObjectsWithTransformation(String indexName, I
67606760
return saveObjectsWithTransformation(indexName, objects, null);
67616761
}
67626762

6763+
/**
6764+
* Helper: Similar to the `saveObjects` method but requires a Push connector
6765+
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)
6766+
* to be created first, in order to transform records before indexing them to Algolia. The
6767+
* `region` must have been passed to the client instantiation method.
6768+
*
6769+
* @param indexName The `indexName` to replace `objects` in.
6770+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6771+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6772+
* processed, this operation may slow the total execution time of this method but is more
6773+
* reliable.
6774+
* @throws AlgoliaRetryException When the retry has failed on all hosts
6775+
* @throws AlgoliaApiException When the API sends an http error code
6776+
* @throws AlgoliaRuntimeException When an error occurred during the serialization
6777+
*/
6778+
public <T> List<WatchResponse> saveObjectsWithTransformation(String indexName, Iterable<T> objects, boolean waitForTasks) {
6779+
return saveObjectsWithTransformation(indexName, objects, waitForTasks, null);
6780+
}
6781+
67636782
/**
67646783
* Helper: Similar to the `saveObjects` method but requires a Push connector
67656784
* (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/)

algoliasearch/src/main/java/com/algolia/utils/TaskUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ private TaskUtils() {
1616

1717
public static <T> T retryUntil(Supplier<T> func, Predicate<T> validate, int maxRetries, IntUnaryOperator timeout)
1818
throws AlgoliaRuntimeException {
19+
if (timeout == null) {
20+
timeout = DEFAULT_TIMEOUT;
21+
}
22+
if (maxRetries == 0) {
23+
maxRetries = DEFAULT_MAX_RETRIES;
24+
}
1925
int retryCount = 0;
2026
while (retryCount < maxRetries) {
2127
T resp = func.get();

0 commit comments

Comments
 (0)