mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
Tests at very high scale indicates that the iteration of all connections during websocket broadcast starts to become a bottleneck. To optimize this, we move the channelMember cache from inside web_conn.go to the hubConnectionIndex. This involves adding a new map keyed by the channelID and containing all webConns where the user is a member of that channel. Subsequently, a new method needed to be added to invalidate the cache which previously used to happen in web_conn. And as a last step, we remove the cache from web_conn to reduce SQL queries to the DB. https://mattermost.atlassian.net/browse/MM-61130 ```release-note NONE ```
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/v8/channels/app/platform"
|
|
)
|
|
|
|
func (a *App) TotalWebsocketConnections() int {
|
|
return a.Srv().Platform().TotalWebsocketConnections()
|
|
}
|
|
|
|
func (a *App) GetHubForUserId(userID string) *platform.Hub {
|
|
return a.Srv().Platform().GetHubForUserId(userID)
|
|
}
|
|
|
|
func (a *App) Publish(message *model.WebSocketEvent) {
|
|
a.Srv().Platform().Publish(message)
|
|
}
|
|
|
|
func (ch *Channels) Publish(message *model.WebSocketEvent) {
|
|
ch.srv.Platform().Publish(message)
|
|
}
|
|
|
|
func (a *App) invalidateCacheForChannelMembers(channelID string) {
|
|
a.Srv().Platform().InvalidateCacheForChannelMembers(channelID)
|
|
}
|
|
|
|
func (a *App) invalidateCacheForChannelMembersNotifyProps(channelID string) {
|
|
a.Srv().Platform().InvalidateCacheForChannelMembersNotifyProps(channelID)
|
|
}
|
|
|
|
func (a *App) invalidateCacheForChannelPosts(channelID string) {
|
|
a.Srv().Platform().InvalidateCacheForChannelPosts(channelID)
|
|
}
|
|
|
|
func (a *App) InvalidateCacheForUser(userID string) {
|
|
a.Srv().Platform().InvalidateCacheForUser(userID)
|
|
}
|
|
|
|
func (a *App) invalidateCacheForUserTeams(userID string) {
|
|
a.Srv().Platform().InvalidateCacheForUserTeams(userID)
|
|
}
|
|
|
|
// UpdateWebConnUserActivity sets the LastUserActivityAt of the hub for the given session.
|
|
func (a *App) UpdateWebConnUserActivity(session model.Session, activityAt int64) {
|
|
a.Srv().Platform().UpdateWebConnUserActivity(session, activityAt)
|
|
}
|
|
|
|
// SessionIsRegistered determines if a specific session has been registered
|
|
func (a *App) SessionIsRegistered(session model.Session) bool {
|
|
return a.Srv().Platform().SessionIsRegistered(session)
|
|
}
|
|
|
|
func (a *App) CheckWebConn(userID, connectionID string) *platform.CheckConnResult {
|
|
return a.Srv().Platform().CheckWebConn(userID, connectionID)
|
|
}
|