From: jw_wonny.cha Date: Mon, 25 Mar 2019 07:59:14 +0000 (+0900) Subject: Remove implements of zmq ipc X-Git-Tag: submit/tizen/20190409.085658~19^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abf88a6d576c96450f4e8e0c386fd8bcbc3f5162;p=platform%2Fcore%2Fsystem%2Fedge-orchestration.git Remove implements of zmq ipc --- diff --git a/src/servicemgr/message_queue.go b/src/servicemgr/message_queue.go deleted file mode 100644 index 2adb3cb..0000000 --- a/src/servicemgr/message_queue.go +++ /dev/null @@ -1,91 +0,0 @@ -package servicemgr - -import ( - "encoding/json" - "fmt" - "log" - - z4 "github.com/alecthomas/gozmq" -) - -// 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()) - return err - } - defer ctx.Close() - - pushSock, err := ctx.NewSocket(z4.PUSH) - if err != nil { - log.Println(err.Error()) - return err - } - defer pushSock.Close() - - pushSock.Connect(fmt.Sprintf("ipc://%d", serviceID)) - - for { - select { - case msg := <-msgChan: - log.Println(string(msg.Body.(string))) - msgBytes, err := json.Marshal(msg) - if err != nil { - log.Println(err.Error()) - return err - } - - // Send msg is non-blocking until 1000 - // Guarantee message, message order - err = pushSock.Send(msgBytes, 0) - case end := <-ctlChan: - if end == true { - return nil - } - } - } -} - -// 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()) - return err - } - defer ctx.Close() - - pullSock, err := ctx.NewSocket(z4.PULL) - if err != nil { - log.Println(err.Error()) - return err - } - defer pullSock.Close() - - pullSock.Bind(fmt.Sprintf("ipc://%d", serviceID)) - - for { - msg, err := pullSock.Recv(0) - if err != nil { - log.Println(err.Error()) - continue - } - - fmt.Println("Recv:", string(msg)) - - parsedMsg := MsgFormat{} - json.Unmarshal(msg, &parsedMsg) - - outputMsg <- parsedMsg - - select { - case end := <-ctlChan: - if end == true { - return nil - } - default: - continue - } - } -}