Skip to content

Commit e473af3

Browse files
author
Ugo Plouviez
authored
Merge pull request #179 from iExecBlockchainComputing/bug1
Add some retry for the result upload
2 parents 122dca7 + d0234d4 commit e473af3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/com/iexec/worker/result/ResultRepoService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import com.iexec.common.result.eip712.Eip712Challenge;
55
import com.iexec.worker.config.PublicConfigurationService;
66
import com.iexec.worker.feign.ResultRepoClient;
7-
87
import feign.FeignException;
98
import lombok.extern.slf4j.Slf4j;
10-
119
import org.springframework.http.ResponseEntity;
10+
import org.springframework.retry.annotation.Backoff;
1211
import org.springframework.retry.annotation.Recover;
1312
import org.springframework.retry.annotation.Retryable;
1413
import org.springframework.stereotype.Service;
@@ -31,7 +30,7 @@ public ResultRepoService(ResultRepoClient resultRepoClient,
3130

3231
@Retryable(value = FeignException.class)
3332
public Optional<Eip712Challenge> getChallenge() {
34-
return Optional.of(resultRepoClient.getChallenge(publicConfigurationService.getChainId()));
33+
return Optional.of(resultRepoClient.getChallenge(publicConfigurationService.getChainId()));
3534
}
3635

3736
@Recover
@@ -41,19 +40,21 @@ public Optional<Eip712Challenge> getResultRepoChallenge(FeignException e, Intege
4140
return Optional.empty();
4241
}
4342

44-
@Retryable(value = FeignException.class)
43+
@Retryable(value = FeignException.class,
44+
maxAttempts = 5,
45+
backoff = @Backoff(delay = 3000))
4546
public String uploadResult(String authorizationToken, ResultModel resultModel) {
4647
ResponseEntity<String> responseEntity =
4748
resultRepoClient.uploadResult(authorizationToken, resultModel);
48-
49+
4950
return responseEntity.getStatusCode().is2xxSuccessful()
5051
? responseEntity.getBody()
5152
: "";
5253
}
5354

5455
@Recover
5556
public String uploadResult(FeignException e, String authorizationToken, ResultModel resultModel) {
56-
log.error("Failed to upload result [attempts:3]");
57+
log.error("Failed to upload result [attempts:5]");
5758
e.printStackTrace();
5859
return "";
5960
}

0 commit comments

Comments
 (0)