[MM-58745] export/import: enable exporting and importing bots canonically (#28214)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2024-11-01 19:44:30 +01:00
коммит произвёл GitHub
родитель 3049191e2f
Коммит f41d2d7774
20 изменённых файлов: 806 добавлений и 75 удалений

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

@@ -596,6 +596,48 @@ func (s *RetryLayerBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot,
}
func (s *RetryLayerBotStore) GetAllAfter(limit int, afterId string) ([]*model.Bot, error) {
tries := 0
for {
result, err := s.BotStore.GetAllAfter(limit, afterId)
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
}
timepkg.Sleep(100 * timepkg.Millisecond)
}
}
func (s *RetryLayerBotStore) GetByUsername(username string) (*model.Bot, error) {
tries := 0
for {
result, err := s.BotStore.GetByUsername(username)
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
}
timepkg.Sleep(100 * timepkg.Millisecond)
}
}
func (s *RetryLayerBotStore) PermanentDelete(userID string) error {
tries := 0