[ Server ] accomplish alive status precedure

This commit is contained in:
zeaslity
2023-06-20 10:02:49 +08:00
parent 92a2a16aea
commit a96d3e51ac
33 changed files with 497 additions and 170 deletions

View File

@@ -30,7 +30,6 @@ func BuildOMsgRuntimeConnectorQueue(agentTopicName string) {
// 建立 业务消息 返回队列
// 统一为 OctopusToServer
octopusToServerQueueName := agentConfig.GetString("octopus.message.octopus_to_server")
octopusToServerProp := &ConnectProperty{

View File

@@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"strings"
"time"
)
var P = g.G.P
@@ -33,11 +32,11 @@ type OctopusMsgBuilder interface {
type OctopusMessage struct {
UUID string `json:"uuid"`
InitTime time.Time `json:"init_time" format:"2023-03-21 16:38:30"`
InitTime string `json:"init_time" format:"2023-03-21 16:38:30"`
Type string `json:"type"`
Content interface{} `json:"content"`
Result interface{} `json:"result"`
ACTime time.Time `json:"ac_time" format:"2023-03-21 16:38:30"`
ACTime string `json:"ac_time" format:"2023-03-21 16:38:30"`
}
func (om *OctopusMessage) Handle() {
@@ -52,7 +51,7 @@ func (om *OctopusMessage) Send(rabbitQueue *RabbitQueue, msg []byte) {
func (om *OctopusMessage) Build(omType string, content interface{}) *OctopusMessage {
// 当前时间
curTimeString := utils.CurTimeString()
curTimeString := utils.ParseDateTimeTime()
// must write to string format, otherwise it's very hard to deserialize
bytes, err := json.Marshal(content)
@@ -62,11 +61,11 @@ func (om *OctopusMessage) Build(omType string, content interface{}) *OctopusMess
return &OctopusMessage{
UUID: curTimeString,
InitTime: time.Now(),
InitTime: curTimeString,
Type: omType,
Content: string(bytes),
Result: nil,
ACTime: time.Time{},
ACTime: curTimeString,
}
}
@@ -134,7 +133,7 @@ func statusOMHandler(octopusMessage *OctopusMessage) {
}
var statusRes string
if strings.HasPrefix(statusMessage.Type, "p") {
if strings.HasPrefix(statusMessage.StatusType, "P") {
// ping info
statusRes = status.Ping()
} else {
@@ -144,7 +143,14 @@ func statusOMHandler(octopusMessage *OctopusMessage) {
}
// 返回消息
// 组装消息
octopusMessage.ACTime = utils.ParseDateTimeTime()
octopusMessage.Result = statusRes
// 发送回去
statusOctopusReplayMessage, _ := json.Marshal(octopusMessage)
OctopusToServerQueue.Send(statusOctopusReplayMessage)
// 输出日志
log.InfoF("接收到查询Agent状态的请求结果为 => %s", statusRes)
}