Skip to content

refactor(go): API 클라이언트 DI 패턴 적용#259

Merged
kubrickcode merged 1 commit intomainfrom
develop/shlee/258
Nov 27, 2025
Merged

refactor(go): API 클라이언트 DI 패턴 적용#259
kubrickcode merged 1 commit intomainfrom
develop/shlee/258

Conversation

@kubrickcode
Copy link
Owner

매 API 호출마다 새로운 HTTP 클라이언트를 생성하던 구조를 개선하여 클라이언트를 재사용할 수 있도록 DI 패턴 적용

  • APIClient 인터페이스 정의로 테스트 시 mock 주입 가능
  • 각 Scraper 생성자가 client를 주입받도록 변경

fix #258

@github-actions github-actions bot added the refactor Refactoring code label Nov 27, 2025
@kubrickcode
Copy link
Owner Author

/gemini review

@gemini-code-assist
Copy link

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 Go 애플리케이션 내 API 클라이언트 사용 방식을 리팩토링하여 의존성 주입(DI) 패턴을 도입합니다. 기존에는 API 호출마다 새로운 HTTP 클라이언트를 생성했지만, 이제는 클라이언트를 재사용하고 외부에서 주입받도록 변경하여 리소스 효율성을 높이고 테스트 용이성을 크게 개선했습니다. 이 변경사항은 여러 스크래퍼 애플리케이션에 걸쳐 적용되었으며, API 클라이언트의 모듈화와 유연성을 강화합니다.

Highlights

  • API 클라이언트 DI 패턴 적용: 매 API 호출마다 새로운 HTTP 클라이언트를 생성하던 기존 구조를 개선하여 클라이언트를 재사용할 수 있도록 의존성 주입(DI) 패턴을 적용했습니다.
  • 테스트 용이성 향상: APIClient 인터페이스를 정의하여 테스트 시 실제 API 클라이언트 대신 mock 객체를 주입할 수 있게 되어 단위 테스트가 훨씬 용이해졌습니다.
  • 스크래퍼 생성자 변경: 각 스크래퍼(auction-item-stat-scraper, market-item-category-scraper, market-item-scraper, market-item-stat-scraper)의 생성자가 이제 API 클라이언트를 주입받도록 변경되었습니다.
  • 새로운 API 클라이언트 인터페이스 및 구현: src/go/libs/loa-api/request/client.go 파일이 추가되어 APIClient 인터페이스와 이를 구현하는 Client 구조체가 정의되었습니다. 기존 API 호출 함수들은 Client의 메서드로 변경되었습니다.
  • 시장 아이템 카테고리 스크래퍼 테스트 추가: src/go/apps/market-item-category-scraper/scraper/scraper_test.go 파일이 새로 추가되어 API 클라이언트 목킹을 활용한 단위 테스트가 작성되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 API 클라이언트 생성 로직을 개선하여 DI 패턴을 적용하고 클라이언트를 재사용하도록 리팩터링했습니다. 이를 통해 HTTP 클라이언트가 매번 생성되는 비효율을 개선하고, 인터페이스 기반 의존성 주입으로 테스트 용이성을 높인 점이 좋습니다. 특히 market-item-category-scraper에 대한 테스트 코드를 추가하여 리팩터링의 이점을 잘 보여주셨습니다. 몇 가지 개선점을 제안드렸으며, 전반적으로 코드 품질을 향상시키는 좋은 변경이라고 생각합니다.

매 API 호출마다 새로운 HTTP 클라이언트를 생성하던 구조를 개선하여 클라이언트를 재사용할 수 있도록 DI 패턴 적용

- APIClient 인터페이스 정의로 테스트 시 mock 주입 가능
- 각 Scraper 생성자가 client를 주입받도록 변경

fix #258
@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

API 클라이언트 생성 로직을 리팩터링하여 DI 패턴을 적용하고 HTTP 클라이언트를 재사용하도록 개선한 점이 좋습니다. 이를 통해 성능이 향상되고 의존성 주입을 통해 테스트 용이성이 높아졌습니다. 전반적으로 훌륭한 리팩터링이며, 코드 품질을 더욱 높일 수 있는 몇 가지 개선 사항을 제안합니다.

@kubrickcode kubrickcode merged commit 087f44b into main Nov 27, 2025
6 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/258 branch November 27, 2025 13:05
@kubrickcode
Copy link
Owner Author

🎉 This PR is included in version 0.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring code released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API 클라이언트 DI 패턴 적용

1 participant