[优化]设备数据上传并发处理,添加队列,以及并发数控制

This commit is contained in:
PandaX
2023-11-28 18:08:49 +08:00
parent 287c8a1b05
commit fd44f11c4b
4 changed files with 12 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ func InitHttpHook(addr string, hs *hook_message_work.HookService) {
if etoken != nil {
data := netbase.CreateConnectionInfo(message.DisConnectMes, "http", conn.RemoteAddr().String(), conn.RemoteAddr().String(), etoken.(*model.DeviceAuth))
activeConnections.Delete(conn.RemoteAddr().String())
service.HookService.MessageCh <- data
service.HookService.Queue.Queue(data)
}
}
}
@@ -87,7 +87,7 @@ func (hhs *HookHttpService) hook(req *restful.Request, resp *restful.Response) {
if !ok {
activeConnections.Store(req.Request.RemoteAddr, etoken)
data := netbase.CreateConnectionInfo(message.ConnectMes, "http", req.Request.RemoteAddr, req.Request.RemoteAddr, etoken)
hhs.HookService.MessageCh <- data
hhs.HookService.Queue.Queue(data)
}
marshal, _ := json.Marshal(upData)
data := &netbase.DeviceEventInfo{
@@ -122,6 +122,6 @@ func (hhs *HookHttpService) hook(req *restful.Request, resp *restful.Response) {
resp.Write([]byte("路径上报类型错误"))
return
}
hhs.HookService.MessageCh <- data
hhs.HookService.Queue.Queue(data)
io.WriteString(resp, "ok")
}