summaryrefslogtreecommitdiffstats
path: root/model/cluster_info.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-08-04 09:25:37 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-08-04 13:25:37 -0400
commit59d971dc751b0414c5b38c9df4b552e45f5641be (patch)
treed8c39aa5d1fa67d41d89bdd37f699a8e7ca7af36 /model/cluster_info.go
parentac90f5b38962c301318fff9118c4556537002941 (diff)
downloadchat-59d971dc751b0414c5b38c9df4b552e45f5641be.tar.gz
chat-59d971dc751b0414c5b38c9df4b552e45f5641be.tar.bz2
chat-59d971dc751b0414c5b38c9df4b552e45f5641be.zip
PLT-2899 adding clustering of app servers (#3682)
* PLT-2899 adding clustering of app servers * PLT-2899 base framework * PLT-2899 HA backend * PLT-2899 Fixing config file * PLT-2899 adding config syncing * PLT-2899 set System console to readonly when clustering enabled. * PLT-2899 Fixing publish API * PLT-2899 fixing strings
Diffstat (limited to 'model/cluster_info.go')
-rw-r--r--model/cluster_info.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/model/cluster_info.go b/model/cluster_info.go
new file mode 100644
index 000000000..7c3384ae2
--- /dev/null
+++ b/model/cluster_info.go
@@ -0,0 +1,66 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type ClusterInfo struct {
+ Id string `json:"id"`
+ Version string `json:"version"`
+ ConfigHash string `json:"config_hash"`
+ InterNodeUrl string `json:"internode_url"`
+ Hostname string `json:"hostname"`
+ LastSuccessfulPing int64 `json:"last_ping"`
+ IsAlive bool `json:"is_alive"`
+}
+
+func (me *ClusterInfo) ToJson() string {
+ b, err := json.Marshal(me)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func ClusterInfoFromJson(data io.Reader) *ClusterInfo {
+ decoder := json.NewDecoder(data)
+ var me ClusterInfo
+ err := decoder.Decode(&me)
+ if err == nil {
+ return &me
+ } else {
+ return nil
+ }
+}
+
+func (me *ClusterInfo) HaveEstablishedInitialContact() bool {
+ if me.Id != "" {
+ return true
+ }
+
+ return false
+}
+
+func ClusterInfosToJson(objmap []*ClusterInfo) string {
+ if b, err := json.Marshal(objmap); err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func ClusterInfosFromJson(data io.Reader) []*ClusterInfo {
+ decoder := json.NewDecoder(data)
+
+ var objmap []*ClusterInfo
+ if err := decoder.Decode(&objmap); err != nil {
+ return make([]*ClusterInfo, 0)
+ } else {
+ return objmap
+ }
+}