-
Notifications
You must be signed in to change notification settings - Fork 0
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
hw5 #6
hw5 #6
Conversation
Задания 1 и 2 реализовала, 3 и 4 постараюсь сделать в ближайшие день-два |
Доделала задания 3 и 4 (получение обновлений и отправка боту) |
CommandUtils.checkParamsNumber(params, 1); | ||
String link = params[0]; | ||
Link.parse(link); | ||
config.linkParser().parse(link); |
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.
Так использовать бины конфигурации - плохая практика. Необходимо их самих инжетить, конфигурацию не инжектим:
public TrackCommand(ScrapperService service, LinkParser linkParser) {
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.
Например - это чревато циклическими зависимостями. При отдельных бинах вы вытаскиваете отдельный бин из контекста, а когда конфиг инжектите - то вероятность циклической зависимости (т е падения при старте приложения) увеличивается. Ну и просто инжектить конфиги - плохая практика, они как обертки для создания методов-@bean. Вот пример возможных проблем с циклическими зависимостями, которые связаны с @configuration
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.
Большое спасибо за объяснение! Теперь стало понятно, запомню и так делать больше не буду)
} | ||
|
||
@Override | ||
public Link remove(long tgId, URI url) throws LinkNotFoundException, ChatNotFoundException { |
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.
Здесь у нас группа операций на обновление, но транзакции нет. Необходимо поставить @transactional над методом, что бы метод был атомарным. Там где присутсвует выборка обновления либо более одной выборки в БД необходимо делать транзакцию. В противном случае будет несколько транзакций на уровне БД
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.
Добавила @transactional к сервисам jdbc. Внутри сервиса обращений к другим сервисам нет, только к репозиториям.
Хотела сделать merge hw5, чтобы решить все конфликты и git actions снова стал работать, но побоялась, что тогда PR закроется. |
No description provided.