Skip to content

Conversation

@ado591
Copy link
Owner

@ado591 ado591 commented Feb 25, 2024

No description provided.

@github-actions
Copy link

github-actions bot commented Feb 25, 2024

Code Coverage

Overall Project 69.04% -30.46% 🍏
Files changed 69.29% 🍏

File Coverage
CommandDescription.java 100% 🍏
ListCommand.java 100% 🍏
Command.java 100% 🍏
Start.java 100% 🍏
ApplicationConfig.java 100% 🍏
ErrorMessage.java 100% 🍏
SuccessMessage.java 100% 🍏
InfoMessage.java 100% 🍏
LinkManager.java 82.93% -17.07% 🍏
UserManager.java 74.59% -25.41% 🍏
LinkBot.java 59.26% -40.74% 🍏
Untrack.java 35.42% -64.58% 🍏
Track.java 35.42% -64.58% 🍏
Help.java 27.42% -72.58%
UserMessageProcessor.java 21.77% -78.23%

Copy link

@edikgoose edikgoose left a 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()) {

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)

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

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;

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

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

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")

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.

3 participants