(VOL-5046)Removing gprc redial in case of disconnect so that it will use the old grpc object when connection to the server comes back up. Also the connect state has to be cahnged to disconnected only once the disconnect event is raised not before it, otherwise the back off interval wont be honoured for the first time
Change-Id: I7929d2b4c72632af9951686e736d336fc27ce702
diff --git a/pkg/grpc/client.go b/pkg/grpc/client.go
index 307da44..d61a509 100644
--- a/pkg/grpc/client.go
+++ b/pkg/grpc/client.go
@@ -262,9 +262,6 @@
c.stateLock.Lock()
if !c.done && (c.state == stateConnected || c.state == stateValidatingConnection) {
// Handle only connected state here. We need the validating state to know if we need to backoff before a retry
- if c.state == stateConnected {
- c.state = stateDisconnected
- }
logger.Warnw(ctx, "sending-disconnect-event", log.Fields{"api-endpoint": c.serverEndPoint, "client": c.clientEndpoint, "curr-state": stateConnected, "new-state": c.state})
c.events <- eventDisconnected
} else {
@@ -532,7 +529,7 @@
connectionValidationFail := false
c.stateLock.Lock()
logger.Debugw(ctx, "endpoint-disconnected", log.Fields{"api-endpoint": c.serverEndPoint, "curr-state": c.state, "client": c.clientEndpoint})
- if c.state == stateValidatingConnection {
+ if c.state == stateConnected || c.state == stateValidatingConnection {
connectionValidationFail = true
c.state = stateDisconnected
}
@@ -554,7 +551,7 @@
}
c.connectionLock.RLock()
if !c.done {
- c.events <- eventConnecting
+ c.events <- eventValidatingConnection
}
c.connectionLock.RUnlock()