discoverymgr/.go : refactory discoverymgr 73/204373/1
authorjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 23 Apr 2019 09:58:57 +0000 (18:58 +0900)
committerjaehoon.hyun <jaehoon.hyun@samsung.com>
Tue, 23 Apr 2019 09:58:57 +0000 (18:58 +0900)
remove go channel
remove go function

Change-Id: I7e59861074f4a0f86d73dbd8b35887de838389ef

src/discoverymgr/configure.go
src/discoverymgr/discovery_execution.go

index 54f1ec5..83f965e 100755 (executable)
@@ -32,3 +32,6 @@ const (
 
 // ExitChan is orchestration agent exit chan
 var ExitChan chan int
+
+// ExitPollingOutBoundCh is polling stop
+var ExitPollingOutBoundCh chan int
index 359a854..9f02add 100755 (executable)
@@ -18,6 +18,7 @@ package discoverymgr
 
 import (
        "context"
+       "errors"
        "log"
        "net"
        "time"
@@ -25,8 +26,12 @@ import (
        "grandcat/zeroconf"
 )
 
-//GetDeviceList retune device list
+//GetDeviceList return device list
 func GetDeviceList() ([]DeviceReturnInfo, error) {
+       if gServer == nil {
+               return nil, errors.New("zeroconf server is nil")
+       }
+
        gServer.IsInterfaceChange()
 
        zeroconf.MapMTX.Lock()
@@ -44,6 +49,9 @@ func GetDeviceList() ([]DeviceReturnInfo, error) {
 
 //GetDeviceListWithService retune device list
 func GetDeviceListWithService(target string) ([]string, error) {
+       if gServer == nil {
+               return nil, errors.New("zeroconf server is nil")
+       }
        gServer.IsInterfaceChange()
 
        zeroconf.MapMTX.Lock()
@@ -92,6 +100,7 @@ func discoveryBGR() {
 }
 
 func discoverDevice(t int) (map[string][]string, error) {
+
        domain := "local"
 
        // Options for IPType.
@@ -120,10 +129,10 @@ func discoverDevice(t int) (map[string][]string, error) {
        go func(results <-chan *zeroconf.ServiceEntry) {
                for entry := range results {
                        deviceIP := entry.AddrIPv4[0].String()
-                       log.Println(logPrefix, "Discoverd Device: "+deviceIP)
                        ServiceNames := make([]string, len(entry.Text))
                        ServiceNames = entry.Text
                        data[deviceIP] = ServiceNames
+                       log.Println(logPrefix, "Discoverd Device: "+deviceIP)
                }
        }(entries)
 
@@ -136,5 +145,8 @@ func discoverDevice(t int) (map[string][]string, error) {
 
        <-ctx.Done()
 
+       // ExitChan <- 1
+       // InitDiscovery()
+
        return data, nil
 }