Skip to content

Commit

Permalink
feat(sync): Add wait for task with requests options
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Nov 7, 2017
1 parent 4ea6b89 commit 141cb67
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.algolia.search.APIClient;
import com.algolia.search.exceptions.AlgoliaException;
import com.algolia.search.objects.RequestOptions;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import javax.annotation.Nonnull;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -20,7 +22,7 @@ public Task setAPIClient(APIClient apiClient) {
* @throws AlgoliaException
*/
public void waitForCompletion() throws AlgoliaException {
apiClient.waitTask(this, 100);
waitForCompletion(RequestOptions.empty);
}

/**
Expand All @@ -30,7 +32,29 @@ public void waitForCompletion() throws AlgoliaException {
* @throws AlgoliaException
*/
public void waitForCompletion(long timeToWait) throws AlgoliaException {
apiClient.waitTask(this, timeToWait);
waitForCompletion(timeToWait, RequestOptions.empty);
}

/**
* Wait for the completion of this task
*
* @param requestOptions Options to pass to this request
* @throws AlgoliaException
*/
public void waitForCompletion(@Nonnull RequestOptions requestOptions) throws AlgoliaException {
waitForCompletion(100, requestOptions);
}

/**
* Wait for the completion of this task
*
* @param timeToWait the time to wait in milliseconds
* @param requestOptions Options to pass to this request
* @throws AlgoliaException
*/
public void waitForCompletion(long timeToWait, @Nonnull RequestOptions requestOptions)
throws AlgoliaException {
apiClient.waitTask(this, timeToWait, requestOptions);
}

@Override
Expand Down

0 comments on commit 141cb67

Please sign in to comment.