| | |
| | | "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 { |
| | | // 进程名字 |
| | |
| | | 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 单个进程服务 |
| | |
| | | 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 |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | Subproject commit 611a497108ec9d66646e98daaec5cf94da8ad02d |
| | | Subproject commit e8145a8ad902a0b9a05f3ccfb9868647875b3880 |
| | |
| | | cd $v |
| | | echo "~~~~~~push $v~~~~~~" |
| | | git add . |
| | | git commit -m '"$1"' |
| | | git commit -m "$1" |
| | | git push |
| | | cd .. |
| | | done |
| | |
| | | Subproject commit 5f90d4aca3149f7e9e1a5913b84e2486110cae2b |
| | | Subproject commit 7b7113002207028ca7e9342fef2b02168f070a34 |
| | |
| | | Subproject commit 9283a3299c95cd940fa49cf9f0e39aa033bf1f83 |
| | | Subproject commit a93f6febea26558c208654a94f09fecd5637777a |
| | |
| | | Subproject commit bf4b1327f286039a1bd9a2abeae2ed51db6128de |
| | | Subproject commit eb7b3a3a8d7af5c051cb706669c0577f79b9813c |