summaryrefslogtreecommitdiffstats
path: root/app/cluster_handlers.go
blob: 892bf00d324bbe5de69b684e3e8903fb9b3de304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"strings"

	"github.com/mattermost/platform/einterfaces"
	"github.com/mattermost/platform/model"
)

func RegisterAllClusterMessageHandlers() {
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_PUBLISH, ClusterPublishHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_UPDATE_STATUS, ClusterUpdateStatusHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_ALL_CACHES, ClusterInvalidateAllCachesHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOK, ClusterInvalidateCacheForWebhookHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_POSTS, ClusterInvalidateCacheForChannelPostsHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS, ClusterInvalidateCacheForChannelMembersNotifyPropHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS, ClusterInvalidateCacheForChannelMembersHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME, ClusterInvalidateCacheForChannelByNameHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL, ClusterInvalidateCacheForChannelHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER, ClusterInvalidateCacheForUserHandler)
	einterfaces.GetClusterInterface().RegisterClusterMessageHandler(model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER, ClusterClearSessionCacheForUserHandler)

}

func ClusterPublishHandler(msg *model.ClusterMessage) {
	event := model.WebSocketEventFromJson(strings.NewReader(msg.Data))
	PublishSkipClusterSend(event)
}

func ClusterUpdateStatusHandler(msg *model.ClusterMessage) {
	status := model.StatusFromJson(strings.NewReader(msg.Data))
	AddStatusCacheSkipClusterSend(status)
}

func ClusterInvalidateAllCachesHandler(msg *model.ClusterMessage) {
	InvalidateAllCachesSkipSend()
}

func ClusterInvalidateCacheForWebhookHandler(msg *model.ClusterMessage) {
	InvalidateCacheForWebhookSkipClusterSend(msg.Data)
}

func ClusterInvalidateCacheForChannelPostsHandler(msg *model.ClusterMessage) {
	InvalidateCacheForChannelPostsSkipClusterSend(msg.Data)
}

func ClusterInvalidateCacheForChannelMembersNotifyPropHandler(msg *model.ClusterMessage) {
	InvalidateCacheForChannelMembersNotifyPropsSkipClusterSend(msg.Data)
}

func ClusterInvalidateCacheForChannelMembersHandler(msg *model.ClusterMessage) {
	InvalidateCacheForChannelMembersSkipClusterSend(msg.Data)
}

func ClusterInvalidateCacheForChannelByNameHandler(msg *model.ClusterMessage) {
	InvalidateCacheForChannelByNameSkipClusterSend(msg.Props["id"], msg.Props["name"])
}

func ClusterInvalidateCacheForChannelHandler(msg *model.ClusterMessage) {
	InvalidateCacheForChannelSkipClusterSend(msg.Data)
}

func ClusterInvalidateCacheForUserHandler(msg *model.ClusterMessage) {
	InvalidateCacheForUserSkipClusterSend(msg.Data)
}

func ClusterClearSessionCacheForUserHandler(msg *model.ClusterMessage) {
	ClearSessionCacheForUserSkipClusterSend(msg.Data)
}