fix 删除爬虫的问题

This commit is contained in:
陈景阳
2019-09-30 12:09:37 +08:00
parent 41123695ef
commit d80642aa0c
20 changed files with 240 additions and 142 deletions

View File

@@ -2,47 +2,34 @@ package msg_handler
import (
"crawlab/constants"
"crawlab/model"
"crawlab/entity"
)
type Handler interface {
Handle() error
}
func GetMsgHandler(msg NodeMessage) Handler {
func GetMsgHandler(msg entity.NodeMessage) Handler {
if msg.Type == constants.MsgTypeGetLog || msg.Type == constants.MsgTypeRemoveLog {
// 日志相关
return &Log{
msg: msg,
}
} else if msg.Type == constants.MsgTypeCancelTask {
// 任务相关
return &Task{
msg: msg,
}
} else if msg.Type == constants.MsgTypeGetSystemInfo {
// 系统信息相关
return &SystemInfo{
msg: msg,
}
} else if msg.Type == constants.MsgTypeRemoveSpider {
// 爬虫相关
return &Spider{
SpiderId: msg.SpiderId,
}
}
return nil
}
type NodeMessage struct {
// 通信类别
Type string `json:"type"`
// 任务相关
TaskId string `json:"task_id"` // 任务ID
// 节点相关
NodeId string `json:"node_id"` // 节点ID
// 日志相关
LogPath string `json:"log_path"` // 日志路径
Log string `json:"log"` // 日志
// 系统信息
SysInfo model.SystemInfo `json:"sys_info"`
// 错误相关
Error string `json:"error"`
}