Update types of servicemgr
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Mon, 25 Mar 2019 07:58:02 +0000 (16:58 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Mon, 25 Mar 2019 07:58:02 +0000 (16:58 +0900)
src/servicemgr/service_map.go
src/servicemgr/types.go

index 75c90a1..a9517d8 100644 (file)
@@ -13,11 +13,11 @@ func CreateServiceMap(cmd *exec.Cmd, serviceName string, appName string) (uint64
 
        value := make(map[string]interface{})
 
-       value[KeyAppName] = appName
-       value[KeyServiceName] = serviceName
-       value[KeyCmd] = cmd
-       value[KeyMsgChan] = msgChan
-       value[KeyCtlChan] = ctlChan
+       value[ConstKeyAppName] = appName
+       value[ConstKeyServiceName] = serviceName
+       value[ConstKeyCmd] = cmd
+       value[ConstKeyMsgChan] = msgChan
+       value[ConstKeyCtlChan] = ctlChan
 
        ServiceMap.Set(serviceID, value)
 
@@ -38,68 +38,68 @@ func DeleteServiceMap(serviceID uint64) {
 func GetAppName(serviceID uint64) (string, error) {
        value, _ := ServiceMap.Get(serviceID)
        if value == nil {
-               return "", errInvalidService
+               return "", ErrInvalidService
        }
 
        valueList := value.(map[string]interface{})
-       return valueList[KeyAppName].(string), nil
+       return valueList[ConstKeyAppName].(string), nil
 }
 
 // GetServiceName function
 func GetServiceName(serviceID uint64) (string, error) {
        value, _ := ServiceMap.Get(serviceID)
        if value == nil {
-               return "", errInvalidService
+               return "", ErrInvalidService
        }
 
        valueList := value.(map[string]interface{})
-       return valueList[KeyServiceName].(string), nil
+       return valueList[ConstKeyServiceName].(string), nil
 }
 
 // GetCmd function
 func GetCmd(serviceID uint64) (*exec.Cmd, error) {
        value, _ := ServiceMap.Get(serviceID)
        if value == nil {
-               return nil, errInvalidService
+               return nil, ErrInvalidService
        }
 
        valueList := value.(map[string]interface{})
-       return valueList[KeyCmd].(*exec.Cmd), nil
+       return valueList[ConstKeyCmd].(*exec.Cmd), nil
 }
 
 // SetCmd function
 func SetCmd(serviceID uint64, cmd *exec.Cmd) error {
        value, _ := ServiceMap.Get(serviceID)
        if value == nil {
-               return errInvalidService
+               return ErrInvalidService
        }
 
        valueList := value.(map[string]interface{})
-       valueList[KeyCmd] = cmd
+       valueList[ConstKeyCmd] = cmd
        return nil
 }
 
-// GetMsgChan function
-func GetMsgChan(serviceID uint64) (chan MsgFormat, error) {
-       value, _ := ServiceMap.Get(serviceID)
-       if value == nil {
-               return nil, errInvalidService
-       }
-
-       valueList := value.(map[string]interface{})
-       return valueList[KeyMsgChan].(chan MsgFormat), nil
-}
-
-// GetCtlChan function
-func GetCtlChan(serviceID uint64) (chan bool, error) {
-       value, _ := ServiceMap.Get(serviceID)
-       if value == nil {
-               return nil, errInvalidService
-       }
-
-       valueList := value.(map[string]interface{})
-       return valueList[KeyCtlChan].(chan bool), nil
-}
+// @TODO GetMsgChan function
+// func GetMsgChan(serviceID uint64) (chan MsgFormat, error) {
+//     value, _ := ServiceMap.Get(serviceID)
+//     if value == nil {
+//             return nil, ErrInvalidService
+//     }
+
+//     valueList := value.(map[string]interface{})
+//     return valueList[ConstKeyMsgChan].(chan MsgFormat), nil
+// }
+
+// @TODO GetCtlChan function
+// func GetCtlChan(serviceID uint64) (chan bool, error) {
+//     value, _ := ServiceMap.Get(serviceID)
+//     if value == nil {
+//             return nil, ErrInvalidService
+//     }
+
+//     valueList := value.(map[string]interface{})
+//     return valueList[ConstKeyCtlChan].(chan bool), nil
+// }
 
 // getServiceIdx() is for getting global serviceID
 func getServiceIdx() uint64 {
index ce38f53..f8ac65d 100644 (file)
@@ -12,19 +12,18 @@ type ServiceParam struct {
 
 // DistService structure
 type DistService struct {
-       SystemParam SystemParam `json:"SystemParam"`
-       UserParam   UserParam   `json:"UserParam"`
+       UserArgs    []string         `json:"UserArgs"`
+       SystemArgs  []string         `json:"SystemArgs"`
+       RelatedArgs []RelatedService `json:"RelatedServices"`
 }
 
-// SystemParam structure
-type SystemParam struct {
-       IP   string `json:"IP"`
-       Port int    `json:"Port"`
-}
-
-// UserParam structure
-type UserParam struct {
-       Args []string `json:"Args"`
+// RelatedService structrue
+type RelatedService struct {
+       ServiceName string `json:"ServiceName"`
+       ServiceID   uint64 `json:"ServiceID"`
+       ServiceType string `json:"ServiceType"`
+       IPAddr      string `json:"IPAddr"`
+       Port        int    `json:"Port"`
 }
 
 // ErrorType structure
@@ -32,23 +31,24 @@ type ErrorType struct {
        ErrorCode string `json:"ErrorCode"`
 }
 
-// ServiceCreationResponse structure
-type ServiceCreationResponse struct {
-       Return string `json:"Return"`
+// ServiceExecutionResponse structure
+type ServiceExecutionResponse struct {
+       Status string `json:"Status"`
 }
 
 // ServiceDestroyResponse structure
 type ServiceDestroyResponse struct {
-       Return string `json:"return"`
+       Return string `json:"Return"`
 }
 
-// ServiceExecutionResponse structure
-type ServiceExecutionResponse struct {
-       ServiceList []ServiceExecutionItem `json:"ServiceList"`
+// ServiceCreationResponse structure
+type ServiceCreationResponse struct {
+       Status      string                        `json:"Status"`
+       ServiceList []ServiceCreationResponseItem `json:"ServiceList"`
 }
 
-// ServiceExecutionItem structure
-type ServiceExecutionItem struct {
+// ServiceCreationResponseItem structure
+type ServiceCreationResponseItem struct {
        ID   uint64 `json:"ID"`
        Time string `json:"Time"`
 }