-
Notifications
You must be signed in to change notification settings - Fork 0
first commit #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
first commit #1
Conversation
agneum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за вариант решения.
Выглядит неплохо, однако есть замечания по основной функциональности, не хватает тестирования разных сценариев и не выполнены обязательные требования к репозиторию по проекту
Возвращаю задачу на доработку
internal/server/http/server.go
Outdated
| fetchedFilePath := fmt.Sprintf("%s/%s_%s_%s.jpg", cnf.UploadPath, width, height, uid) | ||
|
|
||
| if resp, err := file_search.FetchFileFromURL(imageUrl, fetchedFilePath, logger); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оригинальные файлы остаются на диске, в том числе и после вытеснения из кэша
agneum
left a comment
There was a problem hiding this 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. Возвращаю задание на доработку
.golangci.bck.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Копию можно добавить в gitignore и не коммитить
cmd/previewer/main.go
Outdated
| if err := server.Stop(ctx); err != nil { | ||
| logs.Error().Msg(fmt.Sprintf("failed to stop http server: %s", err.Error())) | ||
| } | ||
| }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вопрос всё ещё актуальный. Почему здесь горутина?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пробные и дебаг-файлы желательно не коммитить
internal/filesearch/filesearch.go
Outdated
| "github.com/rs/zerolog" | ||
| ) | ||
|
|
||
| func FetchFileFromURL(imageURL, outputPath string, logger *zerolog.Logger) (*http.Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Заголовки оригинального запроса не проксируются
agneum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за правки. Принято
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выглядит так, что этот файл не относится к коду
| if len(parts) < 3 { | ||
| return nil, errors.New("not enough parts") | ||
| } | ||
|
|
||
| height, width, imageURL := parts[0], parts[1], strings.Join(parts[2:], "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ручной парсинг, перенесённый внутрь пакет, не решает проблему. По-прежнему рекомендую использовать возможности роутинга стандартной библиотеки
| 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень неоптимально, что на каждый запрос создаётся новая структура.
Лучше создать её один раз при старте, а параметры запроса передать в качестве аргументов функции
No description provided.