2020
2121import java .util .List ;
2222import java .util .concurrent .CompletableFuture ;
23+ import java .util .concurrent .TimeUnit ;
2324
2425import com .fasterxml .jackson .core .JsonProcessingException ;
2526import io .vertx .core .Vertx ;
@@ -39,15 +40,15 @@ public class WebClientWrapper {
3940 private final WebClient webClient ;
4041 private final ConvertMapperProvider convertMapperProvider ;
4142 private final PeerNodesManager peerManagers ;
42- private final long timeout ;
43+ private final long timeoutInMillisecond ;
4344
4445 public WebClientWrapper (
4546 final ConvertMapperProvider convertMapperProvider ,
4647 final PeerNodesManager peerManagers ,
47- final long timeout ) {
48+ final long timeoutInMillisecond ) {
4849 this .peerManagers = peerManagers ;
4950 this .convertMapperProvider = convertMapperProvider ;
50- this .timeout = timeout ;
51+ this .timeoutInMillisecond = TimeUnit . SECONDS . toMillis ( timeoutInMillisecond ) ;
5152 this .webClient = WebClient .create (Vertx .vertx (), new WebClientOptions ());
5253 }
5354
@@ -68,7 +69,7 @@ public CompletableFuture<HttpResponse<Buffer>> sendToLeader(
6869
6970 webClient
7071 .post (leader .port (), leader .host (), endpoint )
71- .timeout (timeout )
72+ .timeout (timeoutInMillisecond )
7273 .putHeader ("Content-Type" , CONTENT_TYPE )
7374 .sendJsonObject (
7475 jsonObject ,
@@ -103,7 +104,7 @@ public void sendToFollowers(final String endpoint, final String methodName, fina
103104 peerNode -> {
104105 webClient
105106 .post (peerNode .port (), peerNode .host (), endpoint )
106- .timeout (timeout )
107+ .timeout (timeoutInMillisecond )
107108 .putHeader ("Content-Type" , CONTENT_TYPE )
108109 .sendJsonObject (
109110 jsonObject ,
0 commit comments