Skip to content

Commit ba29db1

Browse files
authored
Fix the bug that no error occurred when client is unavailable (#21)
* Add default deadline (timeout) Signed-off-by: Eric Zhao <sczyh16@gmail.com>
1 parent 626eb8f commit ba29db1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/io/opensergo/OpenSergoClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.opensergo.util.AssertUtils;
3131
import io.opensergo.util.IdentifierUtils;
3232

33+
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.atomic.AtomicInteger;
3435

3536
/**
@@ -48,8 +49,9 @@ public class OpenSergoClient implements AutoCloseable {
4849
private AtomicInteger reqId;
4950

5051
public OpenSergoClient(String host, int port) {
52+
// TODO: support customized config for the OpenSergoClient.
53+
// TODO: support TLS
5154
this.channel = ManagedChannelBuilder.forAddress(host, port)
52-
// TODO: support TLS
5355
.usePlaintext()
5456
.build();
5557
this.transportGrpcStub = OpenSergoUniversalTransportServiceGrpc.newStub(channel);
@@ -59,8 +61,12 @@ public OpenSergoClient(String host, int port) {
5961
}
6062

6163
public void start() throws Exception {
62-
this.requestAndResponseWriter = transportGrpcStub.withWaitForReady()
64+
this.requestAndResponseWriter = transportGrpcStub
65+
.withWaitForReady()
66+
// The deadline SHOULD be set when waitForReady is enabled
67+
.withDeadlineAfter(10, TimeUnit.SECONDS)
6368
.subscribeConfig(new OpenSergoSubscribeClientObserver(configCache, subscribeRegistry));
69+
// TODO: add state management for the client.
6470
}
6571

6672
@Override

0 commit comments

Comments
 (0)