diff options
author | Corey Hulen <corey@hulen.com> | 2017-08-16 10:29:45 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-08-16 10:29:45 -0700 |
commit | 29a7e182a6a9c2970b9c2c2d55062d17f33f084e (patch) | |
tree | f7b84c0e437d50011a968e0a940d4c1566406e99 | |
parent | 0ab490845aed0ce3b58cbffd8ec35be237abda1c (diff) | |
download | chat-29a7e182a6a9c2970b9c2c2d55062d17f33f084e.tar.gz chat-29a7e182a6a9c2970b9c2c2d55062d17f33f084e.tar.bz2 chat-29a7e182a6a9c2970b9c2c2d55062d17f33f084e.zip |
PLT-6079 Adding leader election (#7105)
-rw-r--r-- | app/diagnostics.go | 2 | ||||
-rw-r--r-- | einterfaces/cluster.go | 1 | ||||
-rw-r--r-- | model/cluster_info.go | 1 | ||||
-rw-r--r-- | utils/config.go | 8 |
4 files changed, 11 insertions, 1 deletions
diff --git a/app/diagnostics.go b/app/diagnostics.go index 2eae5871d..1df5b1feb 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -49,7 +49,7 @@ const ( var client *analytics.Client func SendDailyDiagnostics() { - if *utils.Cfg.LogSettings.EnableDiagnostics { + if *utils.Cfg.LogSettings.EnableDiagnostics && utils.IsLeader() { initDiagnostics("") trackActivity() trackConfig() diff --git a/einterfaces/cluster.go b/einterfaces/cluster.go index 096a775fe..9d61b7503 100644 --- a/einterfaces/cluster.go +++ b/einterfaces/cluster.go @@ -14,6 +14,7 @@ type ClusterInterface interface { StopInterNodeCommunication() RegisterClusterMessageHandler(event string, crm ClusterMessageHandler) GetClusterId() string + IsLeader() bool GetClusterInfos() []*model.ClusterInfo SendClusterMessage(cluster *model.ClusterMessage) NotifyMsg(buf []byte) diff --git a/model/cluster_info.go b/model/cluster_info.go index 1e468044e..c4f7e89a6 100644 --- a/model/cluster_info.go +++ b/model/cluster_info.go @@ -10,6 +10,7 @@ import ( ) type ClusterInfo struct { + Id string `json:"id"` Version string `json:"version"` ConfigHash string `json:"config_hash"` IpAddress string `json:"ipaddress"` diff --git a/utils/config.go b/utils/config.go index 187af4125..af88f816e 100644 --- a/utils/config.go +++ b/utils/config.go @@ -653,3 +653,11 @@ func Desanitize(cfg *model.Config) { cfg.SqlSettings.DataSourceSearchReplicas[i] = Cfg.SqlSettings.DataSourceSearchReplicas[i] } } + +func IsLeader() bool { + if IsLicensed && *Cfg.ClusterSettings.Enable && einterfaces.GetClusterInterface() != nil { + return einterfaces.GetClusterInterface().IsLeader() + } else { + return true + } +} |