Skip to content

Conversation

@anon-d
Copy link
Owner

@anon-d anon-d commented Jan 29, 2026

Добавлено асинхронное удаление записей из БД

- 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;
Copy link

@Perederey Perederey left a 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 {

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()
}
}

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()
}
}

Choose a reason for hiding this comment

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

В Go принято всегда проверять ошибки, даже если они маловероятны

@anon-d anon-d merged commit be02568 into main Jan 30, 2026
3 checks passed
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.

2 participants