github.com/rajatvaryani/mattermost-server@v5.11.1+incompatible/model/cluster_message.go (about)

     1  // Copyright (c) 2016-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  const (
    12  	CLUSTER_EVENT_PUBLISH                                           = "publish"
    13  	CLUSTER_EVENT_UPDATE_STATUS                                     = "update_status"
    14  	CLUSTER_EVENT_INVALIDATE_ALL_CACHES                             = "inv_all_caches"
    15  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_REACTIONS                    = "inv_reactions"
    16  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOK                      = "inv_webhook"
    17  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_POSTS                = "inv_channel_posts"
    18  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS = "inv_channel_members_notify_props"
    19  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS              = "inv_channel_members"
    20  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME              = "inv_channel_name"
    21  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL                      = "inv_channel"
    22  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER                         = "inv_user"
    23  	CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER                      = "clear_session_user"
    24  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_ROLES                        = "inv_roles"
    25  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_SCHEMES                      = "inv_schemes"
    26  	CLUSTER_EVENT_INVALIDATE_CACHE_FOR_GROUPS                       = "inv_groups"
    27  
    28  	CLUSTER_SEND_BEST_EFFORT = "best_effort"
    29  	CLUSTER_SEND_RELIABLE    = "reliable"
    30  )
    31  
    32  type ClusterMessage struct {
    33  	Event            string            `json:"event"`
    34  	SendType         string            `json:"-"`
    35  	WaitForAllToSend bool              `json:"-"`
    36  	Data             string            `json:"data,omitempty"`
    37  	Props            map[string]string `json:"props,omitempty"`
    38  }
    39  
    40  func (o *ClusterMessage) ToJson() string {
    41  	b, _ := json.Marshal(o)
    42  	return string(b)
    43  }
    44  
    45  func ClusterMessageFromJson(data io.Reader) *ClusterMessage {
    46  	var o *ClusterMessage
    47  	json.NewDecoder(data).Decode(&o)
    48  	return o
    49  }