func GetRunnableSlotList() ([]*pb.Command,error) { //connecting conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Printf("Connection error:%v", err) logger.Printf("Connection error:%v", err) return nil,err } defer conn.Close() c := pb.NewBoxServiceClient(conn) res,err:=c.GetRunnableSlotList(context.Background(),&empty.Empty{}) if err!=nil{ log.Printf("getRunnableSlotList grpc error:%v",err) logger.Printf("getRunnableSlotList grpc error:%v",err) } return res.Command,nil } func GetRunnableDaemonList() ([]*pb.Command,error) { //connecting conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Printf("Connection error:%v", err) logger.Printf("Connection error:%v", err) return nil,err } defer conn.Close() c := pb.NewBoxServiceClient(conn) res,err:=c.GetRunnableDaemonList(context.Background(),&empty.Empty{}) if err!=nil{ log.Printf("getRunnableDaemonList grpc error:%v",err) logger.Printf("getRunnableDaemonList grpc error:%v",err) } return res.Command,nil } func GetList(tag string)([]*pb.Command,error) { //for testing address=os.Getenv("grpc_server") //connecting conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Printf("Connection error:%v", err) logger.Printf("Connection error:%v", err) return nil,err } defer conn.Close() c := pb.NewBoxServiceClient(conn) switch tag { case "runnableSlot": res,err:=c.GetRunnableSlotList(context.Background(),&empty.Empty{}) if err!=nil{ log.Printf("getRunnableSlotList grpc error:%v",err) logger.Printf("getRunnableSlotList grpc error:%v",err) } return res.Command,nil case "runnableDaemon": res,err:=c.GetRunnableDaemonList(context.Background(),&empty.Empty{}) if err!=nil{ log.Printf("getRunnableDaemonList grpc error:%v",err) logger.Printf("getRunnableDaemonList grpc error:%v",err) } return res.Command,nil case "terminatedDaemon": res,err:=c.GetTerminatedDaemonList(context.Background(),&empty.Empty{}) if err!=nil{ log.Printf("getTerminatedDaemonList grpc error:%v",err) logger.Printf("getTerminatedDaemonList grpc error:%v",err) } return res.Command,nil } return nil, errors.New("no such a tag") }