[Cmii][ImageSync] - reformat agent-go - 2
This commit is contained in:
@@ -73,31 +73,33 @@ func INIT(octopusAgentConfigFileName string, agentServerInfoConf string) chan bo
|
||||
|
||||
// 监听初始化连接中的信息
|
||||
initFromServerQueue := &rabbitmq.RabbitQueue{
|
||||
RabbitProp: initFromServerProp,
|
||||
RabbitProp: initFromServerProp,
|
||||
RabbitConnectInfo: rabbitTCPConnectInfo,
|
||||
}
|
||||
//defer initFromServerQueue.Close()
|
||||
|
||||
// 建立连接
|
||||
initFromServerQueue.Connect()
|
||||
|
||||
initForeverHandle := initFromServerQueue.Handle()
|
||||
initFromServerQueue.Handle()
|
||||
|
||||
buildAndSendInitMsgToServer(agentServerInfo, initToServerQueue)
|
||||
|
||||
// receive from server
|
||||
for g.G.AgentHasRegister == false {
|
||||
select {
|
||||
case <-initFromServerQueue.ReceiveChan.InitRChan:
|
||||
initFromServerMsg := <-initFromServerQueue.ReceiveChan.InitRChan
|
||||
handleInitMsgFromServer(initFromServerMsg, initToServerQueue, agentServerInfo)
|
||||
case initFromServerMsg := <-initFromServerQueue.ReceiveChan.InitRChan:
|
||||
if handleInitMsgFromServer(initFromServerMsg, initToServerQueue, agentServerInfo) {
|
||||
break
|
||||
}
|
||||
default:
|
||||
//log.Debug("")
|
||||
log.Debug("agent init not received from server ! start to waiting !")
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
|
||||
<-initForeverHandle
|
||||
close(initFromServerQueue.ReceiveChan.InitRChan)
|
||||
//<-initForeverHandle
|
||||
//close(initFromServerQueue.ReceiveChan.InitRChan)
|
||||
|
||||
// 建立 运行时 RabbitMQ连接
|
||||
runtimeConnectorQueue := buildAndStartBusinessRuntimeQueue(a_agent.AgentServerInfoCache.TopicName)
|
||||
@@ -194,7 +196,7 @@ func buildAndSendInitMsgToServer(agentServerInfo *a_agent.AgentServerInfo, initT
|
||||
})
|
||||
}
|
||||
|
||||
func BuildOctopusTCPConnect(agentConfig *viper.Viper) rabbitmq.RabbitTCPConnectInfo {
|
||||
func BuildOctopusTCPConnect(agentConfig *viper.Viper) *rabbitmq.RabbitTCPConnectInfo {
|
||||
host := agentConfig.GetString("spring.rabbitmq.host")
|
||||
port := agentConfig.GetString("spring.rabbitmq.port")
|
||||
username := agentConfig.GetString("spring.rabbitmq.username")
|
||||
@@ -202,7 +204,7 @@ func BuildOctopusTCPConnect(agentConfig *viper.Viper) rabbitmq.RabbitTCPConnectI
|
||||
virtualHost := agentConfig.GetString("spring.rabbitmq.virtual-host")
|
||||
|
||||
//todo
|
||||
return rabbitmq.RabbitTCPConnectInfo{
|
||||
return &rabbitmq.RabbitTCPConnectInfo{
|
||||
UserName: username,
|
||||
Password: password,
|
||||
Host: host,
|
||||
@@ -227,7 +229,7 @@ func handleInitMsgFromServer(initFromServerMsg *rabbitmq.OctopusMessage, initToS
|
||||
|
||||
//initOctopusMessageDeliveries := initFromServerQueue.Read(false)
|
||||
|
||||
log.Debug(fmt.Sprintf("message received from server is %s", &initFromServerMsg))
|
||||
log.DebugF("message received from server is %s", initFromServerMsg)
|
||||
|
||||
var serverInfo a_agent.AgentServerInfo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user