Removing certain unneded cluster invalidation messages (#13549)

* Removing certain unneded cluster invalidation messages

* Fixing typo

* Removing channges included in other PR

* Adding doc string to RegisterAllClusterMessageHandlers method

* fixing typos

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-01-08 11:31:10 +01:00
коммит произвёл GitHub
родитель bd480b70f3
Коммит 464c290e50
9 изменённых файлов: 138 добавлений и 61 удалений

Просмотреть файл

@@ -31,7 +31,7 @@ func (s LocalCacheUserStore) ClearCaches() {
}
}
func (s LocalCacheUserStore) InvalidatProfileCacheForUser(userId string) {
func (s LocalCacheUserStore) InvalidateProfileCacheForUser(userId string) {
s.rootStore.doInvalidateCacheCluster(s.rootStore.userProfileByIdsCache, userId)
if s.rootStore.metrics != nil {

Просмотреть файл

@@ -58,7 +58,7 @@ func TestUserStoreGetProfileByIdsCache(t *testing.T) {
assert.Equal(t, fakeUser, gotUser)
mockStore.User().(*mocks.UserStore).AssertNumberOfCalls(t, "GetProfileByIds", 1)
cachedStore.User().InvalidatProfileCacheForUser("123")
cachedStore.User().InvalidateProfileCacheForUser("123")
_, _ = cachedStore.User().GetProfileByIds(fakeUserIds, &store.UserGetByIdsOpts{}, true)
mockStore.User().(*mocks.UserStore).AssertNumberOfCalls(t, "GetProfileByIds", 2)
@@ -91,7 +91,7 @@ func TestUserStoreGetCache(t *testing.T) {
assert.Equal(t, fakeUser, gotUser)
mockStore.User().(*mocks.UserStore).AssertNumberOfCalls(t, "Get", 1)
cachedStore.User().InvalidatProfileCacheForUser("123")
cachedStore.User().InvalidateProfileCacheForUser("123")
_, _ = cachedStore.User().Get(fakeUserId)
mockStore.User().(*mocks.UserStore).AssertNumberOfCalls(t, "Get", 2)

Просмотреть файл

@@ -51,7 +51,7 @@ func (us SqlUserStore) ClearCaches() {
}
}
func (us SqlUserStore) InvalidatProfileCacheForUser(userId string) {}
func (us SqlUserStore) InvalidateProfileCacheForUser(userId string) {}
func NewSqlUserStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) store.UserStore {
us := &SqlUserStore{

Просмотреть файл

@@ -261,7 +261,7 @@ type UserStore interface {
GetProfiles(options *model.UserGetOptions) ([]*model.User, *model.AppError)
GetProfileByIds(userIds []string, options *UserGetByIdsOpts, allowFromCache bool) ([]*model.User, *model.AppError)
GetProfileByGroupChannelIdsForUser(userId string, channelIds []string) (map[string][]*model.User, *model.AppError)
InvalidatProfileCacheForUser(userId string)
InvalidateProfileCacheForUser(userId string)
GetByEmail(email string) (*model.User, *model.AppError)
GetByAuth(authData *string, authService string) (*model.User, *model.AppError)
GetAllUsingAuthService(authService string) ([]*model.User, *model.AppError)

Просмотреть файл

@@ -928,8 +928,8 @@ func (_m *UserStore) InferSystemInstallDate() (int64, *model.AppError) {
return r0, r1
}
// InvalidatProfileCacheForUser provides a mock function with given fields: userId
func (_m *UserStore) InvalidatProfileCacheForUser(userId string) {
// InvalidateProfileCacheForUser provides a mock function with given fields: userId
func (_m *UserStore) InvalidateProfileCacheForUser(userId string) {
_m.Called(userId)
}

Просмотреть файл

@@ -4949,7 +4949,7 @@ func testUserStoreResetLastPictureUpdate(t *testing.T, ss store.Store) {
err = ss.User().ResetLastPictureUpdate(u1.Id)
require.Nil(t, err)
ss.User().InvalidatProfileCacheForUser(u1.Id)
ss.User().InvalidateProfileCacheForUser(u1.Id)
user2, err := ss.User().Get(u1.Id)
require.Nil(t, err)

Просмотреть файл

@@ -552,6 +552,22 @@ func (s *TimerLayerChannelStore) ClearCaches() {
return
}
func (s *TimerLayerChannelStore) CountPostsAfter(channelId string, timestamp int64, userId string) (int, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.ChannelStore.CountPostsAfter(channelId, timestamp, userId)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.CountPostsAfter", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) CreateDirectChannel(userId *model.User, otherUserId *model.User) (*model.Channel, *model.AppError) {
start := timemodule.Now()
@@ -1560,6 +1576,22 @@ func (s *TimerLayerChannelStore) SearchAllChannels(term string, opts ChannelSear
return resultVar0, resultVar1, resultVar2
}
func (s *TimerLayerChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.ChannelStore.SearchArchivedInTeam(teamId, term, userId)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.SearchArchivedInTeam", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) SearchForUserInTeam(userId string, teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
start := timemodule.Now()
@@ -1672,6 +1704,22 @@ func (s *TimerLayerChannelStore) UpdateLastViewedAt(channelIds []string, userId
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID string, mentionCount int) (*model.ChannelUnreadAt, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.ChannelStore.UpdateLastViewedAtPost(unreadPost, userID, mentionCount)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.UpdateLastViewedAtPost", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, *model.AppError) {
start := timemodule.Now()
@@ -2733,14 +2781,13 @@ func (s *TimerLayerGroupStore) GetByName(name string) (*model.Group, *model.AppE
resultVar0, resultVar1 := s.GroupStore.GetByName(name)
t := timemodule.Now()
elapsed := t.Sub(start)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByName", success, float64(elapsed))
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByName", success, elapsed)
}
return resultVar0, resultVar1
}
@@ -2766,14 +2813,13 @@ func (s *TimerLayerGroupStore) GetByUser(userId string) ([]*model.Group, *model.
resultVar0, resultVar1 := s.GroupStore.GetByUser(userId)
t := timemodule.Now()
elapsed := t.Sub(start)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByUser", success, float64(elapsed))
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GetByUser", success, elapsed)
}
return resultVar0, resultVar1
}
@@ -2890,6 +2936,22 @@ func (s *TimerLayerGroupStore) GetMemberUsersPage(groupID string, page int, perP
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) PermanentDeleteMembersByUser(userId string) *model.AppError {
start := timemodule.Now()
resultVar0 := s.GroupStore.PermanentDeleteMembersByUser(userId)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar0 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.PermanentDeleteMembersByUser", success, elapsed)
}
return resultVar0
}
func (s *TimerLayerGroupStore) TeamMembersMinusGroupMembers(teamID string, groupIDs []string, page int, perPage int) ([]*model.UserWithGroups, *model.AppError) {
start := timemodule.Now()
@@ -3674,6 +3736,22 @@ func (s *TimerLayerPluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*mod
return resultVar0, resultVar1
}
func (s *TimerLayerPluginStore) SetWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.PluginStore.SetWithOptions(pluginId, key, value, options)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("PluginStore.SetWithOptions", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerPostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) (int64, *model.AppError) {
start := timemodule.Now()
@@ -5706,6 +5784,22 @@ func (s *TimerLayerTeamStore) SearchAll(term string) ([]*model.Team, *model.AppE
return resultVar0, resultVar1
}
func (s *TimerLayerTeamStore) SearchAllPaged(term string, page int, perPage int) ([]*model.Team, int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1, resultVar2 := s.TeamStore.SearchAllPaged(term, page, perPage)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar2 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.SearchAllPaged", success, elapsed)
}
return resultVar0, resultVar1, resultVar2
}
func (s *TimerLayerTeamStore) SearchOpen(term string) ([]*model.Team, *model.AppError) {
start := timemodule.Now()
@@ -6026,6 +6120,22 @@ func (s *TimerLayerUserStore) Count(options model.UserCountOptions) (int64, *mod
return resultVar0, resultVar1
}
func (s *TimerLayerUserStore) DeactivateGuests() ([]string, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.UserStore.DeactivateGuests()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.DeactivateGuests", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerUserStore) DemoteUserToGuest(userID string) *model.AppError {
start := timemodule.Now()
@@ -6498,7 +6608,7 @@ func (s *TimerLayerUserStore) GetUnreadCount(userId string) (int64, *model.AppEr
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if true {
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.GetUnreadCount", success, elapsed)
@@ -6554,10 +6664,10 @@ func (s *TimerLayerUserStore) InferSystemInstallDate() (int64, *model.AppError)
return resultVar0, resultVar1
}
func (s *TimerLayerUserStore) InvalidatProfileCacheForUser(userId string) {
func (s *TimerLayerUserStore) InvalidateProfileCacheForUser(userId string) {
start := timemodule.Now()
s.UserStore.InvalidatProfileCacheForUser(userId)
s.UserStore.InvalidateProfileCacheForUser(userId)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
@@ -6565,7 +6675,7 @@ func (s *TimerLayerUserStore) InvalidatProfileCacheForUser(userId string) {
if true {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidatProfileCacheForUser", success, elapsed)
s.Root.Metrics.ObserveStoreMethodDuration("UserStore.InvalidateProfileCacheForUser", success, elapsed)
}
return
}