github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/model/cluster_info.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "encoding/json" 8 "io" 9 ) 10 11 type ClusterInfo struct { 12 Id string `json:"id"` 13 Version string `json:"version"` 14 ConfigHash string `json:"config_hash"` 15 IpAddress string `json:"ipaddress"` 16 Hostname string `json:"hostname"` 17 } 18 19 func (me *ClusterInfo) ToJson() string { 20 b, _ := json.Marshal(me) 21 return string(b) 22 } 23 24 func ClusterInfoFromJson(data io.Reader) *ClusterInfo { 25 var me *ClusterInfo 26 json.NewDecoder(data).Decode(&me) 27 return me 28 } 29 30 func ClusterInfosToJson(objmap []*ClusterInfo) string { 31 b, _ := json.Marshal(objmap) 32 return string(b) 33 } 34 35 func ClusterInfosFromJson(data io.Reader) []*ClusterInfo { 36 decoder := json.NewDecoder(data) 37 38 var objmap []*ClusterInfo 39 if err := decoder.Decode(&objmap); err != nil { 40 return make([]*ClusterInfo, 0) 41 } else { 42 return objmap 43 } 44 }