401 응답 시 토큰 갱신 후 1회 재시도. 재시도도 실패 시 TossAuthException.
토스 API가 WebSocket/Push를 미제공하므로 HTTP polling으로 구현.
의존
선행: STK1-01
후행: STK1-04
롤백
외부 연동 — 토스 키 환경변수 미설정 시 호출 비활성.
다이어그램
처리 흐름
sequenceDiagram
participant DS as PriceAlertDomainService
participant GW as TossPriceGateway
participant Toss as Toss OAuth API
participant Price as Toss Price API
DS->>GW: getPrices(symbols)
GW->>Price: GET /price?symbols=...
alt 401 Unauthorized
Price-->>GW: 401
GW->>Toss: POST /oauth/token
Toss-->>GW: access_token
GW->>Price: GET /price?symbols=... (재시도)
alt 재시도도 401
Price-->>GW: 401
GW-->>DS: throw TossAuthException
end
end
Price-->>GW: {"AAPL": 185.20, ...}
GW-->>DS: Map<String, BigDecimal>
클래스 의존
flowchart LR
subgraph Domain["domain"]
PGW[PriceGateway]
end
subgraph Infra["infrastructure"]
TPG[TossPriceGateway]
TokenCache[TokenCache]
end
TPG -.->|implements| PGW
TPG --> TokenCache