|
17 | 17 | import java.util.Map;
|
18 | 18 | import java.util.Random;
|
19 | 19 | import java.util.concurrent.CompletableFuture;
|
| 20 | +import java.util.function.IntUnaryOperator; |
20 | 21 | import java.util.stream.Collectors;
|
21 | 22 | import java.util.stream.Stream;
|
22 | 23 | import okhttp3.Call;
|
@@ -6119,4 +6120,56 @@ public CompletableFuture<UpdateApiKeyResponse> updateApiKeyAsync(
|
6119 | 6120 | ) throws AlgoliaRuntimeException {
|
6120 | 6121 | return this.updateApiKeyAsync(key, apiKey, null);
|
6121 | 6122 | }
|
| 6123 | + |
| 6124 | + public void waitForTask( |
| 6125 | + String indexName, |
| 6126 | + Long taskID, |
| 6127 | + RequestOptions requestOptions, |
| 6128 | + int maxTrial, |
| 6129 | + IntUnaryOperator timeout |
| 6130 | + ) { |
| 6131 | + TaskUtils.retryUntil( |
| 6132 | + () -> { |
| 6133 | + return this.getTaskAsync(indexName, taskID, requestOptions); |
| 6134 | + }, |
| 6135 | + (GetTaskResponse task) -> { |
| 6136 | + return task.getStatus() == TaskStatus.PUBLISHED; |
| 6137 | + }, |
| 6138 | + maxTrial, |
| 6139 | + timeout |
| 6140 | + ); |
| 6141 | + } |
| 6142 | + |
| 6143 | + public void waitForTask( |
| 6144 | + String indexName, |
| 6145 | + Long taskID, |
| 6146 | + RequestOptions requestOptions |
| 6147 | + ) { |
| 6148 | + this.waitForTask( |
| 6149 | + indexName, |
| 6150 | + taskID, |
| 6151 | + requestOptions, |
| 6152 | + TaskUtils.DEFAULT_MAX_TRIAL, |
| 6153 | + TaskUtils.DEFAULT_TIMEOUT |
| 6154 | + ); |
| 6155 | + } |
| 6156 | + |
| 6157 | + public void waitForTask( |
| 6158 | + String indexName, |
| 6159 | + Long taskID, |
| 6160 | + int maxTrial, |
| 6161 | + IntUnaryOperator timeout |
| 6162 | + ) { |
| 6163 | + this.waitForTask(indexName, taskID, null, maxTrial, timeout); |
| 6164 | + } |
| 6165 | + |
| 6166 | + public void waitForTask(String indexName, Long taskID) { |
| 6167 | + this.waitForTask( |
| 6168 | + indexName, |
| 6169 | + taskID, |
| 6170 | + null, |
| 6171 | + TaskUtils.DEFAULT_MAX_TRIAL, |
| 6172 | + TaskUtils.DEFAULT_TIMEOUT |
| 6173 | + ); |
| 6174 | + } |
6122 | 6175 | }
|
0 commit comments