From 8c3d1360e1102bc05545fb9bcf06355276d46dd8 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 21 一月 2020 16:05:26 +0800
Subject: [PATCH] dispatch functions

---
 libcomm/notify.go       |   10 ++++-
 /dev/null               |   14 -------
 libgowrapper/humantrack |    2 
 libgowrapper/vehicle    |    2 
 libgowrapper/gitpush.sh |    2 
 app/master/daemon.go    |   44 ++++++++++++---------
 libgowrapper/face       |    2 
 libgowrapper/yolo       |    2 
 8 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/app/master/daemon.go b/app/master/daemon.go
index 84d626b..8e849b8 100644
--- a/app/master/daemon.go
+++ b/app/master/daemon.go
@@ -12,6 +12,22 @@
 	"analysis/util"
 )
 
+const (
+	opRemove = "remove"
+	opAdd    = "add"
+)
+
+// Notice transit to slave
+type Notice struct {
+	Op      string   `json:"Op"`
+	Content []string `json:"Content"`
+}
+
+type transit struct {
+	chNotify chan<- []byte
+	cancel   context.CancelFunc
+}
+
 // NamedProc 鍗曚釜杩涚▼鍚嶅瓧鍜屾湇鍔¢�氶亾
 type NamedProc struct {
 	// 杩涚▼鍚嶅瓧
@@ -32,16 +48,6 @@
 	Typ string
 	// 鍏峰悕杩涚▼
 	SNameProc []NamedProc
-}
-
-// Notice transit to slave
-type Notice struct {
-	Op      string   `json:"Op"`
-	Content []string `json:"Content"`
-}
-type transit struct {
-	chNotify chan<- []byte
-	cancel   context.CancelFunc
 }
 
 // Worker 鍗曚釜杩涚▼鏈嶅姟
@@ -228,31 +234,31 @@
 				for _, w := range workers {
 					if v == w.info.Name {
 						// 鎵惧埌浜嗗搴斿悕瀛楃殑杩涚▼,棣栧厛姹備笉闇�瑕佸啀杩愯鐨勯�氶亾
-						var notice *Notice
 						removes := difference(w.info.Channels, proc.Channels)
 						if len(removes) > 0 {
 							// 閫氱煡瀛愯繘绋嬪叧闂�氶亾
-							notice = &Notice{
-								Op:      "remove",
+							notice = Notice{
+								Op:      opRemove,
 								Content: removes,
 							}
-
+							if d, err := json.Marshal(notice); err == nil {
+								w.trans.chNotify <- d
+							}
 						}
 
 						// 鍏舵姹傚嚭鏂板鐨勯�氶亾
 						adds := difference(proc.Channels, w.info.Channels)
 						if len(adds) > 0 {
 							// 閫氱煡瀛愯繘绋嬫墦寮�閫氶亾
-							notice = &Notice{
-								Op:      "add",
+							notice = Notice{
+								Op:      opAdd,
 								Content: adds,
 							}
-						}
-						if notice != nil {
-							if d, err := json.Marshal(*notice); err == nil {
+							if d, err := json.Marshal(notice); err == nil {
 								w.trans.chNotify <- d
 							}
 						}
+
 					}
 				}
 			}
diff --git a/libcomm/notify.go b/libcomm/notify.go
index d930c6a..009e2e7 100644
--- a/libcomm/notify.go
+++ b/libcomm/notify.go
@@ -81,11 +81,16 @@
 	}
 }
 
+func getIPCURL(id string) string {
+	return `ipc:///tmp/` + id + `.ipc`
+}
+
 // Notify master sync notify to slave
 func Notify(ctx context.Context, url string, ch <-chan []byte, fn func(...interface{})) context.CancelFunc {
 	rctx, cancel := context.WithCancel(ctx)
 
-	sock := request(url, 2, fn)
+	ipcURL := getIPCURL(url)
+	sock := request(ipcURL, 2, fn)
 
 	go notify(rctx, sock, ch, fn)
 	return cancel
@@ -176,7 +181,8 @@
 func Notifiee(ctx context.Context, url string, ch chan<- []byte, fn func(...interface{})) context.CancelFunc {
 	rctx, cancel := context.WithCancel(ctx)
 
-	sock := reply(url, 2, fn)
+	ipcURL := getIPCURL(url)
+	sock := request(ipcURL, 2, fn)
 
 	go notifiee(rctx, sock, ch, fn)
 	return cancel
diff --git a/libgowrapper/face b/libgowrapper/face
index 611a497..e8145a8 160000
--- a/libgowrapper/face
+++ b/libgowrapper/face
@@ -1 +1 @@
-Subproject commit 611a497108ec9d66646e98daaec5cf94da8ad02d
+Subproject commit e8145a8ad902a0b9a05f3ccfb9868647875b3880
diff --git a/libgowrapper/gitcommit.sh b/libgowrapper/gitcommit.sh
deleted file mode 100755
index 4e370c8..0000000
--- a/libgowrapper/gitcommit.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-cur=`pwd`
-
-for v in `ls`; do
-    if [ ! -d $cur"/"$v ]; then
-        continue
-    fi
-    cd $v
-    echo "~~~~~~pull $v~~~~~~"
-    git add .
-    git commit -m 'update'
-    cd ..
-done
diff --git a/libgowrapper/gitpush.sh b/libgowrapper/gitpush.sh
index 9039261..97667c7 100755
--- a/libgowrapper/gitpush.sh
+++ b/libgowrapper/gitpush.sh
@@ -9,7 +9,7 @@
     cd $v
     echo "~~~~~~push $v~~~~~~"
     git add .
-    git commit -m '"$1"'
+    git commit -m "$1"
     git push
     cd ..
 done
diff --git a/libgowrapper/humantrack b/libgowrapper/humantrack
index 5f90d4a..7b71130 160000
--- a/libgowrapper/humantrack
+++ b/libgowrapper/humantrack
@@ -1 +1 @@
-Subproject commit 5f90d4aca3149f7e9e1a5913b84e2486110cae2b
+Subproject commit 7b7113002207028ca7e9342fef2b02168f070a34
diff --git a/libgowrapper/vehicle b/libgowrapper/vehicle
index 9283a32..a93f6fe 160000
--- a/libgowrapper/vehicle
+++ b/libgowrapper/vehicle
@@ -1 +1 @@
-Subproject commit 9283a3299c95cd940fa49cf9f0e39aa033bf1f83
+Subproject commit a93f6febea26558c208654a94f09fecd5637777a
diff --git a/libgowrapper/yolo b/libgowrapper/yolo
index bf4b132..eb7b3a3 160000
--- a/libgowrapper/yolo
+++ b/libgowrapper/yolo
@@ -1 +1 @@
-Subproject commit bf4b1327f286039a1bd9a2abeae2ed51db6128de
+Subproject commit eb7b3a3a8d7af5c051cb706669c0577f79b9813c

--
Gitblit v1.8.0