-
Notifications
You must be signed in to change notification settings - Fork 0
Iter15 #16
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
Conversation
- feat(repository): added method for getting all user urls (by user_id); - feat(middleware): added security cookie for identificate user; - chore(repository): update migrations; - feat(handler): added handler for getting user urls;
- feat(repository): update model, added batch method for update list; - feat(core): added fanIn worker; - feat(handler): added delete urls handler; - chore(migrations): update migrations;
Perederey
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.
Привет! В целом хорошо справился с заданием!
Из того, на что стоит обратить внимание:
- При переполнении канала ты просто пропускаешь URL (default case), а пользователь получит 202, но URL не удалится. Это проблема
- Два канала захардкожены в коде, лучше сделать конфигурируемым количество
- Service слой не должен лезть в контекст за user_id, это дело handler слоя
- Много дублирования кода (проверка user_id, получение из контекста), выноси в хелперы
А так молодец! Продолжай в том же духе!
| } | ||
|
|
||
| // fanIn объединяет несколько каналов в один | ||
| func (w *DeleteWorker) fanIn(channels ...<-chan DeleteRequest) <-chan DeleteRequest { |
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.
Когда один из входных каналов закрывается, горутина завершается, но выходной канал out никогда не закрывается. Это может привести к тому, что processDeletes будет висеть в ожидании. Нужен механизм отслеживания завершения всех входных каналов через sync.WaitGroup
| c.Next() | ||
| } | ||
| } | ||
|
|
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.
Ключ должен приходить из конфига или environment переменн
| c.Set(UserIDContextKey, userID) | ||
| c.Next() | ||
| } | ||
| } |
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.
В Go принято всегда проверять ошибки, даже если они маловероятны
Добавлено асинхронное удаление записей из БД