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

Develop gosdn cli t2

parent a3876dd3
No related branches found
No related tags found
1 merge request!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; ...@@ -12,6 +12,8 @@ package cliInterface;
service Greeter { service Greeter {
// Sends a greeting // Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {} rpc SayHello (HelloRequest) returns (HelloReply) {}
// Shutdown goSDN
rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {}
} }
// The request message containing the user's name. // The request message containing the user's name.
...@@ -23,3 +25,14 @@ message HelloRequest { ...@@ -23,3 +25,14 @@ message HelloRequest {
message HelloReply { message HelloReply {
string message = 1; 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 ( ...@@ -18,6 +18,7 @@ const (
func main() { func main() {
// Set up a connection to the server. // Set up a connection to the server.
address := "localhost:55055"
conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock()) conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
if err != nil { if err != nil {
log.Fatalf("did not connect: %v", err) log.Fatalf("did not connect: %v", err)
...@@ -37,4 +38,10 @@ func main() { ...@@ -37,4 +38,10 @@ func main() {
log.Fatalf("could not greet: %v", err) log.Fatalf("could not greet: %v", err)
} }
log.Printf("Greeting: %s", r.GetMessage()) 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 ...@@ -26,6 +26,13 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil 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() { func getCLIGoing() {
log.Println("Starting: GetCLIGoing") log.Println("Starting: GetCLIGoing")
// Boot-up the control interface for the cli // Boot-up the control interface for the cli
...@@ -63,12 +70,13 @@ func StartUp() { ...@@ -63,12 +70,13 @@ func StartUp() {
* nucleus.Run() is the "main loop" of the controller * nucleus.Run() is the "main loop" of the controller
*/ */
var isRunning = true
func Run() { func Run() {
isRunning := true
for isRunning { for isRunning {
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
isRunning = false log.Println(("Still alive..."))
} }
log.Println("Good bye....!") 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