Skip to content

Commit

Permalink
Trying to reconnect when the Grpc Client is in IDLE mode (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthiruveedula authored Sep 28, 2022
1 parent 58c61c3 commit 1cf7b02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions proto/client/gClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type Nssai struct {
type ConfigClient struct {
Client protos.ConfigServiceClient
Conn *grpc.ClientConn
Channel chan *protos.NetworkSliceResponse
Host string
Version string
MetadataRequested bool
}
Expand Down Expand Up @@ -70,6 +72,7 @@ func ConnectToConfigServer(host string) ConfClient {
func (confClient *ConfigClient) PublishOnConfigChange(mdataFlag bool) chan *protos.NetworkSliceResponse {
confClient.MetadataRequested = mdataFlag
commChan := make(chan *protos.NetworkSliceResponse)
confClient.Channel = commChan
go confClient.subscribeToConfigPod(commChan)
return commChan
}
Expand Down Expand Up @@ -100,6 +103,7 @@ func CreateChannel(host string, timeout uint32) ConfClient {
client := &ConfigClient{
Client: protos.NewConfigServiceClient(conn),
Conn: conn,
Host: host,
}

return client
Expand Down Expand Up @@ -166,6 +170,10 @@ func (confClient *ConfigClient) subscribeToConfigPod(commChan chan *protos.Netwo
// Retry on failure
continue
}
} else if status == connectivity.Idle {
logger.GrpcLog.Errorf("Connectivity status idle, trying to connect again")
confClient.Conn.Connect()
continue
} else {
//logger.GrpcLog.Errorf("Connectivity status not ready")
continue
Expand Down

0 comments on commit 1cf7b02

Please sign in to comment.