diff options
author | Corey Hulen <corey@hulen.com> | 2017-06-19 08:44:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-19 08:44:04 -0700 |
commit | 36f216cb7cb16958d98b3d77e121198596fd2213 (patch) | |
tree | ac2a5b79494749b3dffc2f5778092f2529c98d1a /model/cluster_message.go | |
parent | fe48987a32fbd600458edd4e81318071ae558ba4 (diff) | |
download | chat-36f216cb7cb16958d98b3d77e121198596fd2213.tar.gz chat-36f216cb7cb16958d98b3d77e121198596fd2213.tar.bz2 chat-36f216cb7cb16958d98b3d77e121198596fd2213.zip |
PLT-6080 moving clustering to memberlist (#6499)
* PLT-6080 adding cluster discovery service
* Adding memberlist lib
* Adding memberlist lib
* WIP
* WIP
* WIP
* WIP
* Rolling back config changes
* Fixing make file
* Fixing config for cluster
* WIP
* Fixing system console for clustering
* Fixing default config
* Fixing config
* Fixing system console for clustering
* Tweaking hub setting
* Bumping up time
* merging vendor dir
* Updating vendor dir
* Fixing unit test
* Fixing bad merge
* Remove some testing code
* Moving comment
* PLT-6868 adding db ping retry
* Removing unused loc strings
* Adding defer to cancel
Diffstat (limited to 'model/cluster_message.go')
-rw-r--r-- | model/cluster_message.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/model/cluster_message.go b/model/cluster_message.go new file mode 100644 index 000000000..a6dec2e7f --- /dev/null +++ b/model/cluster_message.go @@ -0,0 +1,55 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +const ( + CLUSTER_EVENT_PUBLISH = "publish" + CLUSTER_EVENT_UPDATE_STATUS = "update_status" + CLUSTER_EVENT_INVALIDATE_ALL_CACHES = "inv_all_caches" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_REACTIONS = "inv_reactions" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOK = "inv_webhook" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_POSTS = "inv_channel_posts" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS = "inv_channel_members_notify_props" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS = "inv_channel_members" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME = "inv_channel_name" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL = "inv_channel" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER = "inv_user" + CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER = "clear_session_user" + + CLUSTER_SEND_BEST_EFFORT = "best_effort" + CLUSTER_SEND_RELIABLE = "reliable" +) + +type ClusterMessage struct { + Event string `json:"event"` + SendType string `json:"-"` + WaitForAllToSend bool `json:"-"` + Data string `json:"data,omitempty"` + Props map[string]string `json:"props,omitempty"` +} + +func (o *ClusterMessage) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func ClusterMessageFromJson(data io.Reader) *ClusterMessage { + decoder := json.NewDecoder(data) + var o ClusterMessage + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |