Adds a ConnectedWorkspaces.MaxPostsPerSync configuration property (#28154)
* Adds a ConnectedWorkspaces.MaxPostsPerSync configuration property * Fix linter
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d1557271f1
Коммит
d1ae710d45
@@ -24,7 +24,6 @@ const (
|
|||||||
TopicChannelInvite = "sharedchannel_invite"
|
TopicChannelInvite = "sharedchannel_invite"
|
||||||
TopicUploadCreate = "sharedchannel_upload"
|
TopicUploadCreate = "sharedchannel_upload"
|
||||||
MaxRetries = 3
|
MaxRetries = 3
|
||||||
MaxPostsPerSync = 50 // a bit more than 4 typical screenfulls of posts
|
|
||||||
MaxUsersPerSync = 25
|
MaxUsersPerSync = 25
|
||||||
NotifyRemoteOfflineThreshold = time.Second * 10
|
NotifyRemoteOfflineThreshold = time.Second * 10
|
||||||
NotifyMinimumDelay = time.Second * 2
|
NotifyMinimumDelay = time.Second * 2
|
||||||
|
|||||||
@@ -280,12 +280,13 @@ func (scs *Service) fetchPostsForSync(sd *syncData) error {
|
|||||||
LastPostCreateAt: sd.scr.LastPostCreateAt,
|
LastPostCreateAt: sd.scr.LastPostCreateAt,
|
||||||
LastPostCreateID: sd.scr.LastPostCreateID,
|
LastPostCreateID: sd.scr.LastPostCreateID,
|
||||||
}
|
}
|
||||||
|
maxPostsPerSync := *scs.server.Config().ConnectedWorkspacesSettings.MaxPostsPerSync
|
||||||
|
|
||||||
// Fetch all newly created posts first. This is to ensure that post order is preserved for sync targets
|
// Fetch all newly created posts first. This is to ensure that post order is preserved for sync targets
|
||||||
// that cannot set the CreateAt timestamp for incoming posts (e.g. MS Teams). If we simply used UpdateAt
|
// that cannot set the CreateAt timestamp for incoming posts (e.g. MS Teams). If we simply used UpdateAt
|
||||||
// then posts could get out of order. For example: p1 created, p2 created, p1 updated... sync'ing on UpdateAt
|
// then posts could get out of order. For example: p1 created, p2 created, p1 updated... sync'ing on UpdateAt
|
||||||
// would order the posts p2, p1.
|
// would order the posts p2, p1.
|
||||||
posts, nextCursor, err := scs.server.GetStore().Post().GetPostsSinceForSync(options, cursor, MaxPostsPerSync)
|
posts, nextCursor, err := scs.server.GetStore().Post().GetPostsSinceForSync(options, cursor, maxPostsPerSync)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not fetch new posts for sync: %w", err)
|
return fmt.Errorf("could not fetch new posts for sync: %w", err)
|
||||||
}
|
}
|
||||||
@@ -295,10 +296,10 @@ func (scs *Service) fetchPostsForSync(sd *syncData) error {
|
|||||||
cache := postsSliceToMap(posts)
|
cache := postsSliceToMap(posts)
|
||||||
|
|
||||||
// Fill remaining batch capacity with updated posts.
|
// Fill remaining batch capacity with updated posts.
|
||||||
if len(posts) < MaxPostsPerSync {
|
if len(posts) < maxPostsPerSync {
|
||||||
options.SinceCreateAt = false
|
options.SinceCreateAt = false
|
||||||
// use 'nextcursor' as it has the correct xxxUpdateAt values, and the updsted xxxCreateAt values.
|
// use 'nextcursor' as it has the correct xxxUpdateAt values, and the updsted xxxCreateAt values.
|
||||||
posts, nextCursor, err = scs.server.GetStore().Post().GetPostsSinceForSync(options, nextCursor, MaxPostsPerSync-len(posts))
|
posts, nextCursor, err = scs.server.GetStore().Post().GetPostsSinceForSync(options, nextCursor, maxPostsPerSync-len(posts))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not fetch modified posts for sync: %w", err)
|
return fmt.Errorf("could not fetch modified posts for sync: %w", err)
|
||||||
}
|
}
|
||||||
@@ -308,7 +309,7 @@ func (scs *Service) fetchPostsForSync(sd *syncData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sd.resultNextCursor = nextCursor
|
sd.resultNextCursor = nextCursor
|
||||||
sd.resultRepeat = count >= MaxPostsPerSync
|
sd.resultRepeat = count >= maxPostsPerSync
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,6 +894,7 @@ func (ts *TelemetryService) trackConfig() {
|
|||||||
"enable_shared_channels": *cfg.ConnectedWorkspacesSettings.EnableSharedChannels,
|
"enable_shared_channels": *cfg.ConnectedWorkspacesSettings.EnableSharedChannels,
|
||||||
"enable_remote_cluster_service": *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
|
"enable_remote_cluster_service": *cfg.ConnectedWorkspacesSettings.EnableRemoteClusterService && cfg.FeatureFlags.EnableRemoteClusterService,
|
||||||
"disable_shared_channels_status_sync": *cfg.ConnectedWorkspacesSettings.DisableSharedChannelsStatusSync,
|
"disable_shared_channels_status_sync": *cfg.ConnectedWorkspacesSettings.DisableSharedChannelsStatusSync,
|
||||||
|
"max_posts_per_sync": *cfg.ConnectedWorkspacesSettings.MaxPostsPerSync,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Convert feature flags to map[string]any for sending
|
// Convert feature flags to map[string]any for sending
|
||||||
|
|||||||
@@ -265,6 +265,8 @@ const (
|
|||||||
OpenidSettingsDefaultScope = "profile openid email"
|
OpenidSettingsDefaultScope = "profile openid email"
|
||||||
|
|
||||||
LocalModeSocketPath = "/var/tmp/mattermost_local.socket"
|
LocalModeSocketPath = "/var/tmp/mattermost_local.socket"
|
||||||
|
|
||||||
|
ConnectedWorkspacesSettingsDefaultMaxPostsPerSync = 50 // a bit more than 4 typical screenfulls of posts
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDefaultAppCustomURLSchemes() []string {
|
func GetDefaultAppCustomURLSchemes() []string {
|
||||||
@@ -3278,6 +3280,7 @@ type ConnectedWorkspacesSettings struct {
|
|||||||
EnableSharedChannels *bool
|
EnableSharedChannels *bool
|
||||||
EnableRemoteClusterService *bool
|
EnableRemoteClusterService *bool
|
||||||
DisableSharedChannelsStatusSync *bool
|
DisableSharedChannelsStatusSync *bool
|
||||||
|
MaxPostsPerSync *int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConnectedWorkspacesSettings) SetDefaults(isUpdate bool, e ExperimentalSettings) {
|
func (c *ConnectedWorkspacesSettings) SetDefaults(isUpdate bool, e ExperimentalSettings) {
|
||||||
@@ -3300,6 +3303,10 @@ func (c *ConnectedWorkspacesSettings) SetDefaults(isUpdate bool, e ExperimentalS
|
|||||||
if c.DisableSharedChannelsStatusSync == nil {
|
if c.DisableSharedChannelsStatusSync == nil {
|
||||||
c.DisableSharedChannelsStatusSync = NewPointer(false)
|
c.DisableSharedChannelsStatusSync = NewPointer(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.MaxPostsPerSync == nil {
|
||||||
|
c.MaxPostsPerSync = NewPointer(ConnectedWorkspacesSettingsDefaultMaxPostsPerSync)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GlobalRelayMessageExportSettings struct {
|
type GlobalRelayMessageExportSettings struct {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user