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

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

@@ -89,7 +89,7 @@ func (s *HookGrpcService) OnClientConnected(ctx context.Context, in *exhook2.Cli
//添加连接ID
mqttclient.MqttClient.Store(etoken.DeviceId, in.Clientinfo.Clientid)
data := netbase.CreateConnectionInfo(message.ConnectMes, "mqtt", in.Clientinfo.Clientid, in.Clientinfo.Peerhost, etoken)
s.HookService.MessageCh <- data
s.HookService.Queue.Queue(data)
return &exhook2.EmptySuccess{}, nil
}
@@ -104,7 +104,7 @@ func (s *HookGrpcService) OnClientDisconnected(ctx context.Context, in *exhook2.
//删除连接ID
mqttclient.MqttClient.Delete(etoken.DeviceId)
data := netbase.CreateConnectionInfo(message.DisConnectMes, "mqtt", in.Clientinfo.Clientid, in.Clientinfo.Peerhost, etoken)
s.HookService.MessageCh <- data
s.HookService.Queue.Queue(data)
return &exhook2.EmptySuccess{}, nil
}