is this a good for auto recovery ?

22 views
Skip to first unread message

Elhanan Maayan

unread,
Jul 17, 2019, 3:53:44 PM7/17/19
to grpc.io


hi..
i'm trying to create a situation, where the channel will always try to connect and re-connect whether the destination is down, or got disconnected, 

so i'm trying to use notifyStateChanged like so:


final Grpc.Stub stub= Grpc.newStub(channel).withCallCredentials(callCredentials);

final ConnectivityState state = channel.getState(true);// this should force a connection

channel.notifyWhenStateChanged(ConnectivityState.IDLE, new Runnable() {
@Override
public void run() {
final ConnectivityState state = channel.getState(true);
if (ConnectivityState.READY.equals(state)){
final StreamObserver<GrpcProtoSpec.EventRecord> observer = createObserver(event, eventTypes);
stub.getEvents(request, observer);
}
channel.notifyWhenStateChanged(state,this);
}
});


could this be enough?

chengyu...@google.com

unread,
Jul 18, 2019, 7:26:28 PM7/18/19
to grpc.io
Looks ok.
Reply all
Reply to author
Forward
0 new messages