Просмотр исходного кода

add failover existed to server status update

Max Ma 1 год назад
Родитель
Сommit
c3657ce8d5
1 измененных файлов с 19 добавлено и 7 удалено
  1. 19 7
      mq/publishers.go

+ 19 - 7
mq/publishers.go

@@ -15,13 +15,14 @@ import (
 )
 
 type ServerStatus struct {
-	DB               bool      `json:"db_connected"`
-	Broker           bool      `json:"broker_connected"`
-	IsBrokerConnOpen bool      `json:"is_broker_conn_open"`
-	LicenseError     string    `json:"license_error"`
-	IsPro            bool      `json:"is_pro"`
-	TrialEndDate     time.Time `json:"trial_end_date"`
-	IsOnTrialLicense bool      `json:"is_on_trial_license"`
+	DB               bool            `json:"db_connected"`
+	Broker           bool            `json:"broker_connected"`
+	IsBrokerConnOpen bool            `json:"is_broker_conn_open"`
+	LicenseError     string          `json:"license_error"`
+	IsPro            bool            `json:"is_pro"`
+	TrialEndDate     time.Time       `json:"trial_end_date"`
+	IsOnTrialLicense bool            `json:"is_on_trial_license"`
+	Failover         map[string]bool `json:"is_failover_existed"`
 }
 
 // PublishPeerUpdate --- determines and publishes a peer update to all the hosts
@@ -162,6 +163,16 @@ func ServerStatusUpdate() error {
 			isOnTrial = true
 		}
 	}
+	failoverExisted := map[string]bool{}
+	if servercfg.IsPro {
+		networks, err := logic.GetNetworks()
+		if err == nil && len(networks) > 0 {
+			for _, v := range networks {
+				_, b := logic.FailOverExists(v.NetID)
+				failoverExisted[v.NetID] = b
+			}
+		}
+	}
 	currentServerStatus := ServerStatus{
 		DB:               database.IsConnected(),
 		Broker:           IsConnected(),
@@ -170,6 +181,7 @@ func ServerStatusUpdate() error {
 		IsPro:            servercfg.IsPro,
 		TrialEndDate:     trialEndDate,
 		IsOnTrialLicense: isOnTrial,
+		Failover:         failoverExisted,
 	}
 
 	data, err := json.Marshal(currentServerStatus)