return next.newCall(method, callOptions.withDeadlineAfter(10, TimeUnit.SECONDS));
Does the timeout set not take effect?How did they block the thread together and not release the timeout
@Bean
public DgraphClient dgraphClient() {
String[] ips = graphServerIps.split(",");
List<DgraphGrpc.DgraphStub> stubList = new ArrayList<>();
for (String address : ips) {
String[] addr = address.split(":");
if (addr.length != 2)
continue;
String host = addr[0];
Integer port = Integer.parseInt(addr[1]);
ManagedChannel channel = ManagedChannelBuilder
.forAddress(host, port)
.usePlaintext().build();
ClientInterceptor timeoutInterceptor = new ClientInterceptor() {
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
return next.newCall(method, callOptions.withDeadlineAfter(10, TimeUnit.SECONDS));
}
};
DgraphGrpc.DgraphStub stub = DgraphGrpc.newStub(channel);
stub.withInterceptors(timeoutInterceptor);
stubList.add(stub);
}
DgraphGrpc.DgraphStub[] stubs = stubList.toArray(new DgraphGrpc.DgraphStub[stubList.size()]);
return new DgraphClient(stubs);
}