Applied code review
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Wed, 20 Mar 2019 06:18:35 +0000 (15:18 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Wed, 20 Mar 2019 06:18:35 +0000 (15:18 +0900)
src/servicemgr/message_queue.go
src/servicemgr/service_agent.go
src/servicemgr/service_map.go
src/servicemgr/test/mq_test.go
src/servicemgr/test/service_id_test.go

index 71a9306..2adb3cb 100644 (file)
@@ -8,8 +8,8 @@ import (
        z4 "github.com/alecthomas/gozmq"
 )
 
-// Push is zmq push function
-func Push(serviceID uint64, msgChan chan MsgFormat, ctlChan chan bool) error {
+// PushIpcZmq is zmq push function
+func PushIpcZmq(serviceID uint64, msgChan chan MsgFormat, ctlChan chan bool) error {
        ctx, err := z4.NewContext()
        if err != nil {
                log.Println(err.Error())
@@ -47,8 +47,8 @@ func Push(serviceID uint64, msgChan chan MsgFormat, ctlChan chan bool) error {
        }
 }
 
-// Pull is zmq pull function
-func Pull(serviceID uint64, outputMsg chan MsgFormat, ctlChan chan bool) error {
+// PullIpcZmq is zmq pull function
+func PullIpcZmq(serviceID uint64, outputMsg chan MsgFormat, ctlChan chan bool) error {
        ctx, err := z4.NewContext()
        if err != nil {
                log.Println(err.Error())
index 680d42c..415f7f6 100644 (file)
@@ -27,7 +27,7 @@ func Create(serviceParam ServiceParam) []byte {
                id, msgChan, ctlChan := CreateServiceMap(cmd, serviceParam.ServiceName, serviceParam.AppName)
                log.Println("id : ", id)
 
-               go Push(id, msgChan, ctlChan)
+               go PushIpcZmq(id, msgChan, ctlChan)
 
                serviceInfo := ServiceExecutionItem{id, makeTime()}
                ret.ServiceList[index] = serviceInfo
index 589cc8c..75c90a1 100644 (file)
@@ -11,7 +11,7 @@ func CreateServiceMap(cmd *exec.Cmd, serviceName string, appName string) (uint64
        msgChan := make(chan MsgFormat, IPCMsgChan)
        ctlChan := make(chan bool)
 
-       value := make(map[string]interface{}, 5)
+       value := make(map[string]interface{})
 
        value[KeyAppName] = appName
        value[KeyServiceName] = serviceName
index 9f10ed9..81e1716 100644 (file)
@@ -15,7 +15,7 @@ func TestPushMsg(t *testing.T) {
        msgChan := make(chan servicemgr.MsgFormat, servicemgr.IPCMsgChan)
        ctlChan := make(chan bool, 1)
 
-       go servicemgr.Push(uint64(1), msgChan, ctlChan)
+       go servicemgr.PushIpcZmq(uint64(1), msgChan, ctlChan)
        ctx, err := z4.NewContext()
        if err != nil {
                log.Println("Failed to create new context")
@@ -51,8 +51,8 @@ func TestPullMsg(t *testing.T) {
        outputChan := make(chan servicemgr.MsgFormat, servicemgr.IPCMsgChan)
        ctlPullChan := make(chan bool, 1)
 
-       go servicemgr.Pull(uint64(1), outputChan, ctlPullChan)
-       go servicemgr.Push(uint64(1), msgChan, ctlPushChan)
+       go servicemgr.PullIpcZmq(uint64(1), outputChan, ctlPullChan)
+       go servicemgr.PushIpcZmq(uint64(1), msgChan, ctlPushChan)
 
        for index := 0; index < 20; index++ {
                msgChan <- servicemgr.MsgFormat{Header: servicemgr.MsgHeader{Type: "Data"}, Body: strconv.Itoa(index)}
index cb5f044..3a05413 100644 (file)
@@ -45,10 +45,15 @@ func TestReadServiceName(t *testing.T) {
        servicemgr.InitServiceMap()
 
        var cmd *exec.Cmd
-       idx, _, _ := servicemgr.CreateServiceMap(cmd, serviceName, appName)
-
+       idx, _, _ := servicemgr.CreateServiceMap(cmd, serviceName1, appName)
+       t.Log(idx)
        name, _ := servicemgr.GetServiceName(idx)
-       AssertEqualStr(t, name, serviceName)
+       AssertEqualStr(t, serviceName1, serviceName1)
+
+       idx, _, _ = servicemgr.CreateServiceMap(cmd, serviceName2, appName)
+       t.Log(idx)
+       name, _ = servicemgr.GetServiceName(idx)
+       AssertEqualStr(t, name, serviceName2)
 }
 
 func TestRemoveServiceID(t *testing.T) {