44import com .iexec .common .result .eip712 .Eip712Challenge ;
55import com .iexec .worker .config .PublicConfigurationService ;
66import com .iexec .worker .feign .ResultRepoClient ;
7-
87import feign .FeignException ;
98import lombok .extern .slf4j .Slf4j ;
10-
119import org .springframework .http .ResponseEntity ;
10+ import org .springframework .retry .annotation .Backoff ;
1211import org .springframework .retry .annotation .Recover ;
1312import org .springframework .retry .annotation .Retryable ;
1413import 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