* Starting migration

* Lint: remove unnecessary use of sprintf

* Fix i18n

* Some suggestions

* Fix store layers

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Rodrigo Villablanca
2020-09-03 09:19:11 -04:00
коммит произвёл GitHub
родитель d85cec1a4e
Коммит 1ab06ffa7c
10 изменённых файлов: 342 добавлений и 164 удалений

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

@@ -3762,21 +3762,63 @@ func (s *RetryLayerPostStore) GetEtag(channelId string, allowFromCache bool) str
}
func (s *RetryLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
return s.PostStore.GetFlaggedPosts(userId, offset, limit)
tries := 0
for {
result, err := s.PostStore.GetFlaggedPosts(userId, offset, limit)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
return s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
tries := 0
for {
result, err := s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
return s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
tries := 0
for {
result, err := s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
@@ -3804,21 +3846,63 @@ func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterId string
}
func (s *RetryLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
func (s *RetryLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
return s.PostStore.GetPostAfterTime(channelId, time)
tries := 0
for {
result, err := s.PostStore.GetPostAfterTime(channelId, time)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
func (s *RetryLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
func (s *RetryLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
return s.PostStore.GetPostIdAfterTime(channelId, time)
tries := 0
for {
result, err := s.PostStore.GetPostIdAfterTime(channelId, time)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
return s.PostStore.GetPostIdBeforeTime(channelId, time)
tries := 0
for {
result, err := s.PostStore.GetPostIdBeforeTime(channelId, time)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
@@ -3828,9 +3912,23 @@ func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromC
}
func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
return s.PostStore.GetPostsAfter(options)
tries := 0
for {
result, err := s.PostStore.GetPostsAfter(options)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
@@ -3840,9 +3938,23 @@ func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime
}
func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
return s.PostStore.GetPostsBefore(options)
tries := 0
for {
result, err := s.PostStore.GetPostsBefore(options)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}
@@ -3858,9 +3970,23 @@ func (s *RetryLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([
}
func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
return s.PostStore.GetPostsSince(options, allowFromCache)
tries := 0
for {
result, err := s.PostStore.GetPostsSince(options, allowFromCache)
if err == nil {
return result, nil
}
if !isRepeatableError(err) {
return result, err
}
tries++
if tries >= 3 {
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
return result, err
}
}
}