Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc server support #7

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 4 additions & 52 deletions backend/webui_service/webui_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package webui_service
import (
"bufio"
"fmt"
"log"
"os/exec"
"sync"

Expand All @@ -23,8 +22,7 @@ import (
"github.com/free5gc/webconsole/backend/logger"
"github.com/free5gc/webconsole/backend/webui_context"
"github.com/omec-project/webconsole/configapi"
gClient "github.com/omec-project/webconsole/proto/client"
"google.golang.org/grpc/connectivity"
gServ "github.com/omec-project/webconsole/proto/server"
)

type WEBUI struct{}
Expand Down Expand Up @@ -55,54 +53,6 @@ func init() {
initLog = logger.InitLog
}

func startConfigClient() {
var confClient *gClient.ConfigClient
confClient, err := gClient.CreateChannel("nssf:9876", 10000)
if err != nil {
log.Println("create grpc channel to nssf failed. : ", err)
return
}

var cReq gClient.ConfigReq
cReq.SuppPlmnList.PlmnIdList = make([]gClient.PlmnId, 2)
cReq.SuppPlmnList.PlmnIdList[0].MCC = "305"
cReq.SuppPlmnList.PlmnIdList[0].MNC = "11"
cReq.SuppPlmnList.PlmnIdList[1].MCC = "208"
cReq.SuppPlmnList.PlmnIdList[1].MNC = "93"

connReady := make(chan bool)
go func() {
for {
status := confClient.Conn.GetState()
if status == connectivity.Ready {
connReady <- true
}
}
}()

go func() {
select {
case ok := <-connReady:
if ok {
err = confClient.WriteConfig(&cReq)
if err != nil {
log.Println("write config to nssf failed : ", err)
return
}

var cResp gClient.ConfigResp
err = confClient.ReadConfig(&cResp)
if err != nil {
log.Println("write config to nssf failed : ", err)
return
}
}
}
}()

return
}

func (*WEBUI) GetCliCmd() (flags []cli.Flag) {
return webuiCLi
}
Expand All @@ -124,7 +74,9 @@ func (webui *WEBUI) Initialize(c *cli.Context) {
}

webui.setLogLevel()
startConfigClient()
var host string = "0.0.0.0:9876"
confServ := &gServ.ConfigServer{}
go gServ.StartServer(host, confServ)
}

func (webui *WEBUI) setLogLevel() {
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0=
google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
142 changes: 0 additions & 142 deletions proto/client/gClient.go

This file was deleted.

6 changes: 4 additions & 2 deletions proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ message SupportedNssaiInPlmnList {
}

message Config {
SupportedPlmnList suppPlmnList = 1;
SupportedNssaiInPlmnList suppNssaiInPlmnList = 2;
string version = 1;
SupportedPlmnList suppPlmnList = 2;
SupportedNssaiInPlmnList suppNssaiInPlmnList = 3;
}

message WriteRequest {
Expand All @@ -53,6 +54,7 @@ message WriteResponse {
}

message ReadRequest {
string version = 1;
}

message ReadResponse {
Expand Down
102 changes: 61 additions & 41 deletions proto/sdcoreConfig/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.