|
17 | 17 | package bio.overture.song.server.config;
|
18 | 18 |
|
19 | 19 | import lombok.Data;
|
| 20 | +import lombok.val; |
20 | 21 | import org.icgc.dcc.id.client.core.IdClient;
|
21 | 22 | import org.icgc.dcc.id.client.http.HttpIdClient;
|
| 23 | +import org.icgc.dcc.id.client.http.webclient.WebClientConfig; |
22 | 24 | import org.icgc.dcc.id.client.util.HashIdClient;
|
23 | 25 | import org.springframework.boot.context.properties.ConfigurationProperties;
|
24 | 26 | import org.springframework.context.annotation.Bean;
|
|
28 | 30 | @Data
|
29 | 31 | @ConfigurationProperties(prefix = "id")
|
30 | 32 | public class IdConfig {
|
| 33 | + private static final int DEFAULT_MAX_RETRIES = 10; |
| 34 | + private static final float DEFAULT_MULTIPLIER = 2; |
| 35 | + private static final int DEFAULT_INITIAL_BACKOFF_SECONDS = 2; |
31 | 36 |
|
32 | 37 | private String idUrl;
|
33 | 38 | private String authToken;
|
34 | 39 | private boolean realIds;
|
35 | 40 | private boolean persistInMemory = false;
|
| 41 | + private int maxRetries = DEFAULT_MAX_RETRIES; |
| 42 | + private float multiplier = DEFAULT_MULTIPLIER; |
| 43 | + private int initialBackoffSeconds = DEFAULT_INITIAL_BACKOFF_SECONDS; |
36 | 44 |
|
37 | 45 | @Bean
|
38 | 46 | public IdClient createIdClient() {
|
| 47 | + val idClientConfig = WebClientConfig.builder() |
| 48 | + .serviceUrl(idUrl) |
| 49 | + .authToken(authToken) |
| 50 | + .release("") |
| 51 | + .maxRetries(maxRetries) |
| 52 | + .retryMultiplier(multiplier) |
| 53 | + .waitBeforeRetrySeconds(initialBackoffSeconds) |
| 54 | + .build(); |
| 55 | + |
39 | 56 | // [SONG-167]: Temporarily removed cacheId client due to bug in DCC-ID-12: https://github.com/icgc-dcc/dcc-id/issues/12
|
40 |
| - return realIds ? new HttpIdClient(idUrl, "", authToken) : new HashIdClient(persistInMemory); |
| 57 | + return realIds ? new HttpIdClient(idClientConfig) : new HashIdClient(persistInMemory); |
41 | 58 | // return realIds ? new CachingIdClient(new HttpIdClient(idUrl, "", authToken)) : new HashIdClient(persistInMemory);
|
42 | 59 | }
|
43 | 60 |
|
|
0 commit comments