Skip to content
Snippets Groups Projects
Commit 817c1108 authored by Martin Stiemerling's avatar Martin Stiemerling :speech_balloon:
Browse files

Merge branch 'develop-gosdn-cli-t2' into 'develop'

Develop gosdn cli t2

See merge request cocsn/gosdn!20
parents a3876dd3 2d38a7a7
No related branches found
No related tags found
2 merge requests!20Develop gosdn cli t2,!18Develop
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
......@@ -12,6 +12,8 @@ package cliInterface;
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
// Shutdown goSDN
rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {}
}
// The request message containing the user's name.
......@@ -23,3 +25,14 @@ message HelloRequest {
message HelloReply {
string message = 1;
}
// Request to shutdown goSDN
message ShutdownRequest {
string name = 1;
}
// The response message containing some shutdown notes of goSDN
message ShutdownReply {
string message = 1;
}
......@@ -18,6 +18,7 @@ const (
func main() {
// Set up a connection to the server.
address := "localhost:55055"
conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
......@@ -37,4 +38,10 @@ func main() {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Greeting: %s", r.GetMessage())
r2, err := c.Shutdown(ctx, &pb.ShutdownRequest{Name: name})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Greeting: %s", r2.GetMessage())
}
......@@ -26,6 +26,13 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil
}
func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.ShutdownReply, error) {
log.Printf("Received: %v", in.GetName())
isRunning = false
return &pb.ShutdownReply{Message: "Shutdown " + in.GetName()}, nil
}
func getCLIGoing() {
log.Println("Starting: GetCLIGoing")
// Boot-up the control interface for the cli
......@@ -63,12 +70,13 @@ func StartUp() {
* nucleus.Run() is the "main loop" of the controller
*/
var isRunning = true
func Run() {
isRunning := true
for isRunning {
time.Sleep(10 * time.Second)
isRunning = false
log.Println(("Still alive..."))
}
log.Println("Good bye....!")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment