Skip to content

Commit

Permalink
Simplify logic for the GRPC connection state (#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Arrobo, Gabriel <[email protected]>
  • Loading branch information
gab-arrobo authored Feb 28, 2025
1 parent b3b887b commit fbe4e73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.8-dev
1.5.8
15 changes: 4 additions & 11 deletions proto/client/gClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
)
Expand Down Expand Up @@ -64,7 +63,7 @@ type ConfClient interface {
sendMessagesToChannel(commChan chan *protos.NetworkSliceResponse, stream protos.ConfigService_NetworkSliceSubscribeClient)

// CheckGrpcConnectivity checks the connectivity status and returns the state of connectivity
CheckGrpcConnectivity() (state string)
CheckGrpcConnectivity() string

// SubscribeToConfigServer Subscribes to a stream of NetworkSlice
// It returns a stream if subscription is successful else returns nil.
Expand Down Expand Up @@ -155,16 +154,10 @@ func (confClient *ConfigClient) GetConfigClientConn() *grpc.ClientConn {
}

// CheckGrpcConnectivity checks the connectivity status and returns the state of connectivity
func (confClient *ConfigClient) CheckGrpcConnectivity() (state string) {
func (confClient *ConfigClient) CheckGrpcConnectivity() string {
logger.GrpcLog.Debugln("checking GRPC connectivity status")
status := confClient.Conn.GetState()
if status == connectivity.Ready {
return "ready"
} else if status == connectivity.Idle {
return "idle"
} else {
return "unconnected"
}
state := confClient.Conn.GetState()
return state.String()
}

// SubscribeToConfigServer Subscribes to a stream of NetworkSlice
Expand Down

0 comments on commit fbe4e73

Please sign in to comment.