orchEngine it is global variable initialize when Init function called.
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 10:09:45 +0000 (19:09 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 2 Apr 2019 10:09:45 +0000 (19:09 +0900)
serviceClient.listenNotify operate goroutine

src/orchestrationapi/orchstration_api.go

index 901226f51bc380b6c48c69cf502de4e06c2fe130..d3ff5d74b709ef2ced8c12c70a5ffd5b4a967dd9 100644 (file)
@@ -52,11 +52,11 @@ type orcheClient struct {
 var orchClientId int32
 var orcheClients = [1024]orcheClient{}
 
-func Init(settingPath string) {
+func Init(settingPath string) *Orche {
 
   orcheEngine = new(Orche)
 
-  return
+  return orcheEngine
 
 
 }
@@ -67,13 +67,11 @@ func RequestService(libName string, serviceName string, args []string) (handle i
   atomic.AddInt32(&orchClientId, 1)
 
   serviceClient := addServiceClient(clientId, libName, serviceName, args)
-  serviceClient.listenNotify()
+  go serviceClient.listenNotify()
   endpoints := getEndpointDevices(serviceName)
   deviceScores := sortByScore(gatheringDevicesScore(endpoints, libName))
   executeApp(deviceScores[0].endpoint, serviceName, args, serviceClient.notiChan)
 
-  
-
   ILog.Println(deviceScores)
   return
 }
@@ -108,7 +106,10 @@ func getEndpointDevices(serviceName string) []string{
 func gatheringDevicesScore(endpoints []string, libName string) (deviceScores []deviceScore){
 
   for _ , endpoint := range endpoints {
-      score := orcheEngine.IScoringmgr.IGetScore(endpoint, libName)
+      
+      //(chacha)TODO : err occured , notify devicemgr to delete
+      score, _ := orcheEngine.IScoringmgr.IGetScore(endpoint, libName)
+
       deviceScores = append(deviceScores, deviceScore{endpoint, score})
   }