From 30f35de47284269b475c3aa307d06c033b67aa27 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 21 十月 2023 16:46:10 +0800
Subject: [PATCH] 精简topic
---
constvar/const.go | 1 -
nsq/msg_handler.go | 31 +------------------------------
main.go | 9 ++++-----
nsq/consumer.go | 2 --
nsq/nsq.go | 1 -
5 files changed, 5 insertions(+), 39 deletions(-)
diff --git a/constvar/const.go b/constvar/const.go
index ce5eac9..5f6fa74 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -2,7 +2,6 @@
const (
NsqTopicScheduleTask = "aps.%v.scheduleTask" //鎺掔▼浠诲姟涓嬪彂
- NsqTopicSendPlcAddress = "aps.%v.sendPlcAddress" //plc address鏇存柊
NsqTopicApsProcessParams = "aps.%v.aps.processParams" //鏈変簡鏂扮殑宸ヨ壓妯″瀷
NsqTopicTaskProcedureStatusUpdate = "aps.%v.task.procedure.status" //宸ュ簭鐘舵�佹洿鏂�
NsqTopicSyncTaskProgress = "aps.%v.task.procedure.progress" //宸ュ簭鐢熶骇杩涘害
diff --git a/main.go b/main.go
index 7acd081..8aa04c1 100644
--- a/main.go
+++ b/main.go
@@ -47,11 +47,10 @@
agent.RegisterClusterEvent(serfClusterEvent)
go agent.Serve(serfStartChan)
- <-serfStartChan
- //if !<-serfStartChan {
- // logx.Errorf("serf Init err, exit")
- // return
- //}
+ if !<-serfStartChan {
+ logx.Errorf("serf Init err, exit")
+ return
+ }
// 鍒ゆ柇褰撳墠闆嗙兢鐘舵��
logx.Infof("current agent.ClusterStatus:%v", agent.ClusterStatus)
diff --git a/nsq/consumer.go b/nsq/consumer.go
index e8d5655..47c5f90 100644
--- a/nsq/consumer.go
+++ b/nsq/consumer.go
@@ -19,8 +19,6 @@
switch topic {
case fmt.Sprintf(constvar.NsqTopicScheduleTask, conf.Conf.NsqConf.NodeId):
handler = new(ScheduleTask)
- case fmt.Sprintf(constvar.NsqTopicSendPlcAddress, conf.Conf.NsqConf.NodeId):
- handler = &PlcAddress{Topic: topic}
case fmt.Sprintf(constvar.NsqTopicApsProcessParams, conf.Conf.NsqConf.NodeId):
handler = &ProcessParamsSync{Topic: topic}
case fmt.Sprintf(constvar.NsqTopicDeviceUpdate, conf.Conf.NsqConf.NodeId):
diff --git a/nsq/msg_handler.go b/nsq/msg_handler.go
index 63a0e9d..0b3d0d5 100644
--- a/nsq/msg_handler.go
+++ b/nsq/msg_handler.go
@@ -384,34 +384,5 @@
}
func (slf *PullDataResponse) DealDeviceData(data interface{}) error {
- var devices []*model.Device
- err := mapstructure.Decode(data, &devices)
- if err != nil {
- return err
- }
- numbers := make([]string, 0, len(devices))
- for _, item := range devices {
- numbers = append(numbers, item.DeviceID)
- }
- existsDevices, err := model.NewDeviceSearch().SetDeviceIds(numbers).FindNotTotal()
- if err != nil {
- return err
- }
-
- existsDeviceMap := make(map[string]*model.Device, len(existsDevices))
- for _, device := range existsDevices {
- existsDeviceMap[device.DeviceID] = device
- }
-
- for _, device := range devices {
- if oldDevice, exists := existsDeviceMap[device.DeviceID]; exists {
- if oldDevice.ExtChannelAmount != device.ExtChannelAmount || //todo to be continued
- oldDevice.Procedures != device.Procedures {
- err = model.NewDeviceSearch().SetDeviceId(device.DeviceID).Save(device)
- }
- } else {
- err = model.NewDeviceSearch().Create(device)
- }
- }
- return err
+ return nil
}
diff --git a/nsq/nsq.go b/nsq/nsq.go
index c8f7650..68274b2 100644
--- a/nsq/nsq.go
+++ b/nsq/nsq.go
@@ -37,7 +37,6 @@
}
var topics = []string{
constvar.NsqTopicScheduleTask,
- constvar.NsqTopicSendPlcAddress,
constvar.NsqTopicApsProcessParams,
constvar.NsqTopicDeviceUpdate,
constvar.NsqTopicPullDataResponse,
--
Gitblit v1.8.0