Skip to content

Conversation

@DEMAxx
Copy link
Owner

@DEMAxx DEMAxx commented May 3, 2025

No description provided.

Copy link

@agneum agneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо за вариант решения.
Выглядит неплохо, однако есть замечания по основной функциональности, не хватает тестирования разных сценариев и не выполнены обязательные требования к репозиторию по проекту
Возвращаю задачу на доработку

Comment on lines 90 to 92
fetchedFilePath := fmt.Sprintf("%s/%s_%s_%s.jpg", cnf.UploadPath, width, height, uid)

if resp, err := file_search.FetchFileFromURL(imageUrl, fetchedFilePath, logger); err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оригинальные файлы остаются на диске, в том числе и после вытеснения из кэша

Copy link

@agneum agneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо за правки, выглядит лучше, однако остаются актуальными комментарии с прошлого ревью.

  • Реализован HTTP-сервер, проксирующий запросы к удаленному серверу - 1 балл.
  • Реализована нарезка изображений - 2 балла.
  • Кэширование нарезанных изображений на диске - 1 балл.
  • Ограничение кэша одним из способов (LRU кэш) - 1 балл.
  • Прокси сервер правильно передает заголовки запроса - 0 баллов.
  • Написаны интеграционные тесты - 0 балла.
  • Тесты адекватны и полностью покрывают функциональность - 0 балл.
  • Проект возможно собрать через make build, запустить через make run и протестировать через make test - 1 балл.
  • Понятность и чистота кода - 2 балла.

Итого: 8 баллов из 15. Возвращаю задание на доработку

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Копию можно добавить в gitignore и не коммитить

if err := server.Stop(ctx); err != nil {
logs.Error().Msg(fmt.Sprintf("failed to stop http server: %s", err.Error()))
}
}()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вопрос всё ещё актуальный. Почему здесь горутина?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пробные и дебаг-файлы желательно не коммитить

"github.com/rs/zerolog"
)

func FetchFileFromURL(imageURL, outputPath string, logger *zerolog.Logger) (*http.Response, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Заголовки оригинального запроса не проксируются

Copy link

@agneum agneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо за правки. Принято

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выглядит так, что этот файл не относится к коду

Comment on lines +98 to +102
if len(parts) < 3 {
return nil, errors.New("not enough parts")
}

height, width, imageURL := parts[0], parts[1], strings.Join(parts[2:], "/")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ручной парсинг, перенесённый внутрь пакет, не решает проблему. По-прежнему рекомендую использовать возможности роутинга стандартной библиотеки

Comment on lines +65 to +78
modifier, err := filemodifier.New(
ctx,
strings.Split(path, "/"),
logger,
cnf,
cache,
r,
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

cachedImage, found := modifier.GetFromCache()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень неоптимально, что на каждый запрос создаётся новая структура.
Лучше создать её один раз при старте, а параметры запроса передать в качестве аргументов функции

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants