Skip to content

Commit

Permalink
#33 [refactor] : 요청 횟수 제한 고려
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbang105 committed Jun 17, 2024
1 parent a273aa2 commit c1fc136
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,21 @@ private DashBoardDto.UserCoinResponse processSingleCoin(UpbitDto.Account account
@Override
public List<DashBoardDto.RepresentativeCoinResponse> getRepresentativeCoins() {
List<DashBoardDto.RepresentativeCoinResponse> representativeCoinResponses = new ArrayList<>();
int requestCount = 0;

for (Coin coin : Coin.values()) {
UpbitDto.Ticker[] ticker = upbitApiClient.getTickerPriceAtUpbit(UPBIT_URL_TICKER + coin.getMarketName());
representativeCoinResponses.add(DashBoardDto.RepresentativeCoinResponse.of(ticker[0], coin.getKoreanName(), coin.getEnglishName()));

requestCount++;
if (requestCount % 10 == 0) {
try {
Thread.sleep(1000); // 1초 대기
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
}

return representativeCoinResponses;
Expand Down

0 comments on commit c1fc136

Please sign in to comment.