-
Notifications
You must be signed in to change notification settings - Fork 0
Hw2 #2
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: master
Are you sure you want to change the base?
Conversation
Code Coverage
|
edikgoose
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.
Сделано хорошо. Из советов:
- Почитай про паттерны отказоустойчивости. Особенно про таймауты и ретраи (и обязательно добавь их в клиенты). Полезная тема для собесов.
- Дефолтный значения для параметров лучше указывать в том же конфиге (пример есть в одном замечании)
- Тестики все-таки стоит добавить
5/6
|
|
||
|
|
||
| public GitHubClient(String otherUrl) { | ||
| if (!otherUrl.isEmpty()) { |
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.
Лучше храни base-url в application.yaml конфиге в таком виде:
web-client:
github:
base-url: ${GITHUB_BASE_URL:https://...}
read-timeout: ${GITHUB_READ_TIMEOUT:1000}
write-timeout: ${GITHUB_WRITE_TIMEOUT:1000}
retry-count: ${GITHUB_RETRY_COUNT:5}
stackoverflow:
base-url: ... (the same) Тогда если не будет указан в env'е урлик, то он возьмет дефолтное значение после двоеточия
| public GitDTO fetch(String username, String repositoryName) { | ||
| return webClient.get().uri("/repos/%s/%s".formatted(username, repositoryName)) | ||
| .retrieve() | ||
| .bodyToMono(GitDTO.class) |
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.
Почитай про ретраи и как их применять. Полезная тема
| return webClient.get().uri(param -> param | ||
| .path("/questions/%d".formatted(questionId)) | ||
| .queryParam("site", "stackoverflow").build()) | ||
| .retrieve().bodyToMono(StackDTO.class).block(); |
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.
Лучше все-таки на рахных строчках
|
|
||
| @Configuration | ||
| public class ClientConfiguration { | ||
| final ApplicationConfig config; |
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 (!otherUrl.isEmpty()) { | ||
| this.baseUrl = otherUrl; | ||
| } | ||
| this.webClient = WebClient.builder().baseUrl(otherUrl).build(); |
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 class ClientConfiguration { | ||
| final ApplicationConfig config; | ||
|
|
||
| @Value("${clients.github}") |
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.
Лучше создать property класс, где префиксом указать "clients". И инжектить уже его.
@ConfigurationProperties(prefix = "clients")
No description provided.