This commit is contained in:
xzb 2023-10-26 17:58:59 +08:00
commit 31a394aecc
4 changed files with 14 additions and 2 deletions

View File

@ -12,6 +12,9 @@ type IMsgServer interface {
// 构造定时发送的消息
OnTick() ([]*TopicMsg, error)
// 当发生错误时执行的逻辑
OnError(err error)
}
// 消息实体

View File

@ -59,8 +59,9 @@ func run(server *MsgServer) {
}
topicMsgs, err := server.OnTick()
if err != nil {
slog.Error("消息服务构建定时发送消息错误", "channel", server.GetChannel(), "error", err)
continue
server.OnError(err)
slog.Error("消息服务构建定时发送消息错误,服务退出", "channel", server.GetChannel(), "error", err)
break
}
if len(topicMsgs) > 0 {
for _, msg := range topicMsgs {

View File

@ -84,6 +84,10 @@ func (ms *SfpMs) OnTick() ([]*ms_api.TopicMsg, error) {
return []*ms_api.TopicMsg{ms_api.NewTopicMsg(ms.channel, b)}, nil
}
func (ms *SfpMs) OnError(err error) {
// TODO: 错误处理
}
// 收集屏蔽门状态
func (ms *SfpMs) collectPsdStates() ([]*state.PsdState, error) {
// TODO: 重构之前的消息服务

View File

@ -66,3 +66,7 @@ func (sms *SimulationMs) OnTick() ([]*ms_api.TopicMsg, error) {
}
return tmList, nil
}
func (sms *SimulationMs) OnError(err error) {
// TODO: 仿真消息错误处理
}