change interface scoringmgr, configuremgr
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Fri, 29 Mar 2019 09:13:01 +0000 (18:13 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Fri, 29 Mar 2019 09:13:01 +0000 (18:13 +0900)
src/configuremgr/configuremgr_test.go
src/configuremgr/description/doc.go
src/configuremgr/watchConfPath.go
src/scoringmgr/handlers.go
src/scoringmgr/scoringmgr_test.go

index 5a38180d1ed9740fa49ee0ba32942070e5f6a3f5..538510d043273006ddd893299665ec45a6ba4d4e 100644 (file)
@@ -23,11 +23,11 @@ func TestBasicMockConfigureMgr(t *testing.T){
   //mock function
 
   //test object
-  configuremgrObj  := new(configuremgr.ConfigureMgr)
-  configuremgrObj.IDeviceDiscoveryMgr.PushConfPath  = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
-  configuremgrObj.IAppExecuteMgr.PushConfPath = mockconfiguremgr.PushConfPathAppExecuteMock
-  configuremgrObj.IScoringMgr.PushLibPath     = mockconfiguremgr.PushLibPathScoringAppMock
-  configuremgrObj.Done                        = make(chan bool)
+  configuremgrObj  := configuremgr.Init()
+  configuremgrObj.IDeviceDiscoveryMgr.PushConfPath = mockconfiguremgr.PushConfPathDiscoveryDeviceMock
+  configuremgrObj.IAppExecuteMgr.PushConfPath      = mockconfiguremgr.PushConfPathAppExecuteMock
+  configuremgrObj.IScoringMgr.PushLibPath          = mockconfiguremgr.PushLibPathScoringAppMock
+  
 
   go configuremgrObj.Watch(watchDir)
 
index 7d9a2d480facef5d6ac5b129fad4a61fb2016a82..4dad6f1eaf76dc998869770e7fe06f0d7ee8fe81 100644 (file)
@@ -1,19 +1,18 @@
 package confdescription
 
 type Doc struct {
-               Version struct {
-                       ConfVersion string
-               }
-               ServiceInfo struct {
-                       ServiceName  string
-               }
-               ResourceType struct {
-                       IntervalTimeMs int
-                       MaxCount     int
-               }
-
-               ScoringMethod struct {
-                       LibFile      string
-               }
+  Version struct {
+    ConfVersion string
+  }
+  ServiceInfo struct {
+    ServiceName  string
+  }
+  ResourceType struct {
+    IntervalTimeMs int
+    MaxCount     int
+  }
+  ScoringMethod struct {
+    LibFile      string
+  }
                
 }
\ No newline at end of file
index 8e955d39f759621f26a00dba19a36b8197d238c1..9828707eee2e36350f684df24e036052aae64df6 100644 (file)
@@ -13,21 +13,30 @@ import (
 
 type ConfigureMgr struct {
 
-  IDeviceDiscoveryMgr struct {
+  IDiscoveryMgr struct {
     PushConfPath func(*confdescription.Doc) (error)
   }
 
   IAppExecuteMgr struct {
-    PushConfPath func(*confdescription.Doc) (error)
+    // PushConfPath func(*confdescription.Doc) (error)
+    // ExecuteApp func(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error)
   }
 
   IScoringMgr struct {
-    PushLibPath func(libPath string) (error)
+    PushLibPath func(libPath string, doc *confdescription.Doc, handlersCh chan<- interface{}) (error)
+    Ch chan interface{}
   }
 
   Done chan bool
 }
 
+func Init() (configuremgrObj *ConfigureMgr) {
+  configuremgrObj = new(ConfigureMgr)
+  configuremgrObj.Done = make(chan bool)
+
+  return
+}
+
 func (cfgMgr *ConfigureMgr) installConfigure(path string) {
 
 //1. libPath, conf := diretoryname get
@@ -39,9 +48,9 @@ func (cfgMgr *ConfigureMgr) installConfigure(path string) {
 
   libPath, confPath := cfgMgr.getdirname(path)
   sconf.Must(cfg).Read(ini.File(confPath))
-  cfgMgr.IScoringMgr.PushLibPath(libPath)
-  cfgMgr.IDeviceDiscoveryMgr.PushConfPath(cfg)
-  cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
+  cfgMgr.IScoringMgr.PushLibPath(libPath, cfg, cfgMgr.IScoringMgr.Ch)
+  cfgMgr.IDiscoveryMgr.PushConfPath(cfg)
+  // cfgMgr.IAppExecuteMgr.PushConfPath(cfg)
 
 }
 
@@ -81,7 +90,7 @@ func (cfgMgr *ConfigureMgr) Watch(path string) {
               return
           }
 
-          ELog.Println("log event:", event)
+          ILog.Println("log event:", event)
           if event.Op & fsnotify.Create == fsnotify.Create {
             cfgMgr.installConfigure(event.Name)
           }
index b73018103c76ca0d6c64706f56dd053cc82ef12d..4bb6f5821465155bff5a130c1676295850f6b0fd 100644 (file)
@@ -22,6 +22,7 @@ type Handlers struct {
 
   Ch                  chan interface{}
   IloadScoringLibrary func (string, int) ()
+  GetScore            func (string) float64
 }
 
 
@@ -35,6 +36,8 @@ func Init() (handlers *Handlers){
 
 //TODO : async notify lib loading
 func PushLibPath(libPath string, doc *confdescription.Doc,  handlersCh chan<- interface{}) (err error){
+  ILog.Printf("input PushLibPath : %s", libPath)
+
   handlersCh <- pair{libPath, doc}
   return nil
 }
@@ -48,7 +51,7 @@ func (handlers *Handlers) Listening() {
       
       select {
         case obj := <- handlers.Ch :
-
+          ILog.Printf("input handlers.Ch from configuremgr")
           handlerObj := handlers.makeHandler(obj.(pair))
           handlers.runScoring(handlerObj)
       }
index 8dbc174d5cef270c5923cc616cbdfd226eea8033..a22cf3a5f147ef0b964905a46023eed35f54e91b 100644 (file)
@@ -21,7 +21,7 @@ func TestBasicMockScoringMgr(t *testing.T){
 
   scoringHandlers.Listening()
 
-  time.Sleep(time.Duration(1 * time.Second))
+  time.Sleep(time.Duration(1) * time.Second)
   
   libPath  := "mock/mysum/libmysum.so"
   confPath := "mock/mysum/mysum.conf"
@@ -33,6 +33,4 @@ func TestBasicMockScoringMgr(t *testing.T){
   time.Sleep(time.Duration(5) * time.Second)
 
 
-
-
 }
\ No newline at end of file