Skip to content

Refactor/jira kan 72 환율 및 환전 리팩토링#84

Merged
CryingPerson merged 14 commits intodevelopfrom
Refactor/JIRA-kan-72-환율-및-환전-리팩토링
Apr 8, 2025

Hidden character warning

The head ref may contain hidden characters: "Refactor/JIRA-kan-72-\ud658\uc728-\ubc0f-\ud658\uc804-\ub9ac\ud329\ud1a0\ub9c1"
Merged

Refactor/jira kan 72 환율 및 환전 리팩토링#84
CryingPerson merged 14 commits intodevelopfrom
Refactor/JIRA-kan-72-환율-및-환전-리팩토링

Conversation

@CryingPerson
Copy link
Collaborator

@CryingPerson CryingPerson commented Apr 7, 2025

🛠️ 과제 요약

  • "https://v6.exchangerate-api.com/v6/" + authkey + "/latest/" -> 따로 뺴서 사용할경우 null 문제 발생해서 원래대로 작성
  • 동시사용자 환율 정보 조회시 락 기능 추가
  • 여러명의 사용자가 업데이트 못하게끔
  • 업데이트 될때마다 캐시어블로 저장된 데이터 삭제

📝 요구 사항과 구현 내용

  • PostgreSQL의 Advisory Lock 기능 추가
  • A,B,C 사용자가 있을경우 A 사용자가 락을 획득 하고 나머지 사용자들은 계속해서 DB에 업데이트가 되는동안 재조회를 통해 조회가 될시에 정보를 반환 하는 구조.
  • cache.evict("rate::" + baseCurrency + "::" + targetCurrency); 비동기 처리

✅ 피드백 반영사항

  • 최소의 스레드 수가 코어 수의 2 ~ 4 배라고 했는데 각 스레드별 로드량 구해보고 다시한번 반영해야할거같음.

💬 PR 포인트 & 궁금한 점

  • 지금 로직 몇개 바꿧는데 지금 환율 정보가 안불러와져서 잘 되는지는 다시한번 테스트를 해봐야할듯.

🔗 연관된 이슈

@CryingPerson CryingPerson added the 🔨 Refactor 코드 리팩토링 label Apr 7, 2025
@CryingPerson CryingPerson self-assigned this Apr 7, 2025
@CryingPerson CryingPerson linked an issue Apr 7, 2025 that may be closed by this pull request
1 task
import java.util.concurrent.Executor;

@Service
@RequiredArgsConstructor
Copy link
Collaborator

Choose a reason for hiding this comment

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

RequiredArgsConstructor 사용햇는데 생성자 주입 받고있는데 수정부탁드립니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

고쳤습니다.


exchangeRates = exchangeRepository.findByBaseCurrency(baseCurrency);
if (!exchangeRates.isEmpty()) {
return toResponse(baseCurrency, exchangeRates);
Copy link
Collaborator

Choose a reason for hiding this comment

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

똑같은 코드가 두번 반복됩니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

추후 계속 반복될경우 코드를 빼는 방향으로 가겠습니다.
두번정도는 충분히 괜찮다고 생각합니다.

Copy link
Collaborator

@Si-rauis Si-rauis left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!


public ExchangeRateResponse fetchExchangeRates(String baseCurrency) {
String API_URL = url + baseCurrency;
String API_URL = "https://v6.exchangerate-api.com/v6/" + authkey + "/latest/" + baseCurrency;
Copy link
Collaborator

Choose a reason for hiding this comment

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

global/common 안에 있는 constants 파일에 상수를 보관해서 관리하는게 좋아보입니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정했습니다.

@PersistenceContext
private final EntityManager entityManager;

private static final long LOCK_KEY = 987654321L;
Copy link
Collaborator

Choose a reason for hiding this comment

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

이것도 상수 관리 필드에 옮겨주시면 좋겠습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정했습니다.

@CryingPerson CryingPerson merged commit a48dd13 into develop Apr 8, 2025
1 check passed
@CryingPerson CryingPerson deleted the Refactor/JIRA-kan-72-환율-및-환전-리팩토링 branch April 9, 2025 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAN-72 [Refactor] 환율 및 환전 리팩토링

3 participants