//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)
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
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)
}
return
}
- ELog.Println("log event:", event)
+ ILog.Println("log event:", event)
if event.Op & fsnotify.Create == fsnotify.Create {
cfgMgr.installConfigure(event.Name)
}
Ch chan interface{}
IloadScoringLibrary func (string, int) ()
+ GetScore func (string) float64
}
//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
}
select {
case obj := <- handlers.Ch :
-
+ ILog.Printf("input handlers.Ch from configuremgr")
handlerObj := handlers.makeHandler(obj.(pair))
handlers.runScoring(handlerObj)
}
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"
time.Sleep(time.Duration(5) * time.Second)
-
-
}
\ No newline at end of file