From: jw_wonny.cha Date: Fri, 29 Mar 2019 06:06:49 +0000 (+0900) Subject: - add compare targetURL with "localhost" string X-Git-Tag: submit/tizen/20190409.085658~5^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed8d38c85038ef373670f28235b2c1bd183f2e27;p=platform%2Fcore%2Fsystem%2Fedge-orchestration.git - add compare targetURL with "localhost" string - Add Init() export function --- diff --git a/src/restapi/v1/restapi_test.go b/src/restapi/v1/restapi_test.go index 021e65d..49ce2f0 100644 --- a/src/restapi/v1/restapi_test.go +++ b/src/restapi/v1/restapi_test.go @@ -15,7 +15,6 @@ import ( ) var ( - server *httptest.Server testURL string ) @@ -190,11 +189,11 @@ func executeService(t *testing.T) { func init() { devicemgr.InitDeviceMgr() - servicemgr.InitServiceMap() + servicemgr.Init() discoverymgr.InitDiscovery() router := NewRouter() - server = httptest.NewServer(router) + server := httptest.NewServer(router) testURL = server.URL diff --git a/src/servicemgr/configure.go b/src/servicemgr/configure.go index 106c714..3bfc9d4 100644 --- a/src/servicemgr/configure.go +++ b/src/servicemgr/configure.go @@ -46,7 +46,7 @@ const ( ConstServiceStatusNotiURI = "/api/v1/servicemgr/services/notification/" //ConstLocalTarget is for knowing local environments - ConstLocalTarget = "local" + ConstLocalTarget = "localhost" //ConstPrefixHTTP is "http://" ConstPrefixHTTP = "http://" diff --git a/src/servicemgr/service_map.go b/src/servicemgr/service_map.go index 7c2dbf3..419e98e 100644 --- a/src/servicemgr/service_map.go +++ b/src/servicemgr/service_map.go @@ -4,8 +4,8 @@ import ( "sync/atomic" ) -// InitServiceMap is for initializing service map -func InitServiceMap() { +// initServiceMap is for initializing service map +func initServiceMap() { ServiceMap = ConcurrentMap{items: make(map[uint64]interface{})} } diff --git a/src/servicemgr/servicemgr.go b/src/servicemgr/servicemgr.go index bc5d86b..42fc12a 100644 --- a/src/servicemgr/servicemgr.go +++ b/src/servicemgr/servicemgr.go @@ -11,6 +11,11 @@ import ( "strings" ) +// Init is for initializing serviemgr +func Init() { + initServiceMap() +} + // ExecuteApp function func ExecuteApp(target string, name string, args []string, notiChan chan string) (serviceID uint64, err error) { appInfo := make(map[string]interface{}) @@ -23,7 +28,7 @@ func ExecuteApp(target string, name string, args []string, notiChan chan string) } appInfo[ConstKeyServiceName] = name - if strings.Compare(target, getOutboundIP()) == 0 { + if strings.Compare(target, getOutboundIP()) == 0 || strings.Compare(target, ConstLocalTarget) == 0 { appInfo[ConstKeyNotiTargetURL] = ConstLocalTarget err = executeLocalEnv(appInfo) } else { @@ -37,7 +42,6 @@ func ExecuteApp(target string, name string, args []string, notiChan chan string) // Run is trigger point executing binary func Run(distService map[string]interface{}) { var serviceID uint64 - switch distService[ConstKeyServiceID].(type) { case uint64: serviceID = distService[ConstKeyServiceID].(uint64) @@ -65,10 +69,10 @@ func Run(distService map[string]interface{}) { } else { args = nil } + notificationTargetURL := distService[ConstKeyNotiTargetURL].(string) service := Service{serviceID, serviceName, args, notificationTargetURL} - service.execute() }