Skip to content

[CVW-040] AllMarketTicker플로우, 스트림 구독 요청 주체 변경#52

Merged
J0onYEong merged 8 commits intomainfrom
refactor/WebSocketHelper
Apr 22, 2025
Merged

[CVW-040] AllMarketTicker플로우, 스트림 구독 요청 주체 변경#52
J0onYEong merged 8 commits intomainfrom
refactor/WebSocketHelper

Conversation

@J0onYEong
Copy link
Collaborator

변경된점

  • AllMarketTicker플로우 리팩토링
  • 웹소켓 핸들러 호출 주체 변경(스트림 구독 요청 주체 변경)

AllMarketTicker플로우 리팩토링

기존 플로우

레이어 책임
Presentation 텍스트 가공, 코인 리스트 관리
Domain 코인 리스트 가공, UI업데이트 주기 관리
Data DTO를 엔티티화

#50 , #51 과 비슷한 이유로 리팩토링이 필요하다고 판단했습니다.

변경된 플로우

레이어 책임
Presentation 텍스트 가공, UI업데이트 주기 관리
Domain 도메인 로직 기반 코인 리스트 가공
Data - Repository DTO를 엔티티화
Data - DataSource 리스트 저장 및 관리

웹소켓 핸들러 호출 주체 변경(스트림 구독 요청 주체 변경)

기존 UseCase에서 스트림 연결 요청을 직접 진행하였지만 해당 기능은 바이낸스 API에 의존적인 기능이며 비즈니스 로직과는 무관하다고 생각했습니다.
따라서 ViewModel에서 스트림 구독을 요청하도록 수정했습니다.
스트림 자체는 엔티티로 추상화하여 최대한 외부의존성을 배제시켰습니다.

스트림 엔티티는 아래와 같습니다.

public enum WebSocketStream {
    // AllMarketTicker
    case allMarketTickerChangesIn24h
    
    // CoinDetailPage
    case orderbook(symbolPair: String)
    case tickerChangesIn24h(symbolPair: String)
    case recentTrade(symbolPair: String)
}

전달된 스트림을 외부API의 포맷에 맞는 스트림 문자열로 디코딩하는 객체(StreamDecoder)를 주입하는 방식으로 의존성을 최소화 했습니다.

생성자에서 주입합니다.

public class DefaultWebSocketManagementHelper: WebSocketManagementHelper, WebSocketServiceListener {
    ...

    public init(webSocketService: WebSocketService, streamDecoder: StreamDecoder, alertShootable: AlertShootable) {
        self.webSocketService = webSocketService
        self.streamDecoder = streamDecoder
        self.alertShootable = alertShootable
    }
}

@J0onYEong J0onYEong requested a review from Copilot April 22, 2025 09:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the AllMarketTicker flow and changes the WebSocket handler caller from the UseCase to the ViewModel, while also updating the dependency injection registrations accordingly.

  • Refactored the repository to convert DTOs into an AVLTree instead of an array.
  • Updated the DI assemblies to inject a new stream decoder and remove deprecated exchange rate dependencies.
  • Added new DataSource and interface implementations and removed unused services.

Reviewed Changes

Copilot reviewed 102 out of 102 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Projects/Data/Repository/Sources/BinanceAllMarketTickersRepository.swift Refactored AllMarketTicker repository to return an AVLTree via both a Combine publisher and async method.
Projects/Data/Project.swift Added deployment target configuration to the project.
Projects/Data/DataSource/Sources/Util/LockedDictionary.swift Introduced a thread-safe dictionary utility.
Projects/Data/DataSource/Sources/Service/Network/WebSocket/BinanceWebSocketService.swift Removed an unused dependency import.
Projects/App/Sources/DI/Assembly/SharedAssembly.swift Updated DI registrations to include the new stream decoder and remove obsolete services.
Projects/App/Sources/AppDelegate.swift Removed the direct exchange rate fetch call from the initial tasks.
Others Various new interfaces, DataSources, and DI adjustments supporting the refactored flows.
Comments suppressed due to low confidence (2)

Projects/Data/Repository/Sources/BinanceAllMarketTickersRepository.swift:29

  • [nitpick] Consider renaming the Combine-based getAllMarketTicker method (e.g., to getAllMarketTickerPublisher) so that it is clearly distinguishable from the async version.
public func getAllMarketTicker() -> AnyPublisher<AVLTree<Twenty4HourTickerForSymbolVO>, Never> {

Projects/Data/Repository/Sources/BinanceAllMarketTickersRepository.swift:37

  • [nitpick] Consider renaming the async variant of getAllMarketTicker (e.g., to getAllMarketTickerAsync) to avoid confusion with the publisher-based method.
public func getAllMarketTicker() async -> AVLTree<Twenty4HourTickerForSymbolVO> {

@J0onYEong J0onYEong changed the title [CVW-040] AllMarketTicker플로우, WebSocketHandler호출 주체 변경 [CVW-040] AllMarketTicker플로우, 스트림 구독 요청 주체 변경 Apr 22, 2025
@J0onYEong J0onYEong merged commit 7d1acb3 into main Apr 22, 2025
1 check passed
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.

2 participants