Chuẩn hóa tên file trong internal/data/market theo dimension dữ liệu để dễ đọc và nhất quán, tránh naming theo endpoint/lịch sử implementation.
Problem
Hiện tại package market có naming lẫn lộn (trading_pairs.go, future_price.go, spot_price.go, alpha_tokens.go), làm khó nhận biết trách nhiệm file khi đọc nhanh.
Proposed Direction
Đổi naming về dạng nhất quán theo nhóm dữ liệu:
spot_pairs.go
futures_pairs.go
spot_prices.go
futures_prices.go
giữ alpha_tokens.go
Nguyên tắc: nhìn tên file là biết ngay loại dữ liệu mà file quản lý.
Scope
Đây là rename-only PR (không đổi logic behavior).
Nếu cần chỉnh import/path do rename thì giữ ở mức mechanical update.
Không gộp với các thay đổi logic khác để giảm review noise.
## Summary
Chuẩn hóa tên file trong `internal/data/market` theo dimension dữ liệu để dễ đọc và nhất quán, tránh naming theo endpoint/lịch sử implementation.
## Problem
Hiện tại package market có naming lẫn lộn (`trading_pairs.go`, `future_price.go`, `spot_price.go`, `alpha_tokens.go`), làm khó nhận biết trách nhiệm file khi đọc nhanh.
## Proposed Direction
Đổi naming về dạng nhất quán theo nhóm dữ liệu:
- `spot_pairs.go`
- `futures_pairs.go`
- `spot_prices.go`
- `futures_prices.go`
- giữ `alpha_tokens.go`
Nguyên tắc: nhìn tên file là biết ngay loại dữ liệu mà file quản lý.
## Scope
- Đây là **rename-only PR** (không đổi logic behavior).
- Nếu cần chỉnh import/path do rename thì giữ ở mức mechanical update.
- Không gộp với các thay đổi logic khác để giảm review noise.
## Why separate issue/PR
- Rename tạo diff lớn nhưng ít giá trị logic.
- Tách PR giúp review dễ hơn, giảm rủi ro và giúp blame/history rõ ràng.
alphaCacheRefreshLoop trong main.go hiện không còn được gọi sau khi có cacheRefreshLoop; nên remove trong cùng PR nếu vẫn giữ no-behavior-change.
Acceptance:
Không đổi public behavior.
Không đổi resolver logic.
Không đổi cache semantics.
Chỉ move/rename function giữa files và update test filenames tương ứng.
go test ./... pass.
Như vậy issue #26 vẫn là refactor naming/structure, nhưng tránh rename nửa vời khiến trading_pairs.go tiếp tục là “god file” của market cache.
Mình đã rà lại code hiện tại sau PR canonical maps.
Issue này vẫn hợp lý, nhưng nên chỉnh scope một chút: `trading_pairs.go` hiện không chỉ là “trading pairs” nữa mà đang chứa cả:
- spot pair cache
- futures pair cache
- canonical token -> symbol lookup
- shared quote-priority helpers
- cache refresh orchestration
Vì vậy nếu chỉ rename file thì vẫn chưa sạch về mặt boundary. Đề nghị làm PR này theo hướng move-only / no behavior change:
1. Rename price files:
- `spot_price.go` -> `spot_prices.go`
- `future_price.go` -> `futures_prices.go`
2. Split `trading_pairs.go` theo responsibility:
- `spot_pairs.go`: `refreshSpotPairCache`, `IsSpotPair`, `GetSpotSymbolByToken`
- `futures_pairs.go`: `refreshFuturePairCache`, `IsFuturesPair`, `GetFutureSymbolByToken`, `futureCacheTokenKey`
- `pair_symbols.go` hoặc `symbol_canonical.go`: shared helpers như `parseTokenFromSymbolByQuotePriority`, `selectCanonicalSymbolByQuotePriority`
- `cache_refresh.go`: `refreshTradingPairCache`, `refreshAllCaches`, `cacheRefreshLoop`
3. Clean up small dead-code item:
- `alphaCacheRefreshLoop` trong `main.go` hiện không còn được gọi sau khi có `cacheRefreshLoop`; nên remove trong cùng PR nếu vẫn giữ no-behavior-change.
Acceptance:
- Không đổi public behavior.
- Không đổi resolver logic.
- Không đổi cache semantics.
- Chỉ move/rename function giữa files và update test filenames tương ứng.
- `go test ./...` pass.
Như vậy issue #26 vẫn là refactor naming/structure, nhưng tránh rename nửa vời khiến `trading_pairs.go` tiếp tục là “god file” của market cache.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Chuẩn hóa tên file trong
internal/data/markettheo dimension dữ liệu để dễ đọc và nhất quán, tránh naming theo endpoint/lịch sử implementation.Problem
Hiện tại package market có naming lẫn lộn (
trading_pairs.go,future_price.go,spot_price.go,alpha_tokens.go), làm khó nhận biết trách nhiệm file khi đọc nhanh.Proposed Direction
Đổi naming về dạng nhất quán theo nhóm dữ liệu:
spot_pairs.gofutures_pairs.gospot_prices.gofutures_prices.goalpha_tokens.goNguyên tắc: nhìn tên file là biết ngay loại dữ liệu mà file quản lý.
Scope
Why separate issue/PR
Mình đã rà lại code hiện tại sau PR canonical maps.
Issue này vẫn hợp lý, nhưng nên chỉnh scope một chút:
trading_pairs.gohiện không chỉ là “trading pairs” nữa mà đang chứa cả:Vì vậy nếu chỉ rename file thì vẫn chưa sạch về mặt boundary. Đề nghị làm PR này theo hướng move-only / no behavior change:
Rename price files:
spot_price.go->spot_prices.gofuture_price.go->futures_prices.goSplit
trading_pairs.gotheo responsibility:spot_pairs.go:refreshSpotPairCache,IsSpotPair,GetSpotSymbolByTokenfutures_pairs.go:refreshFuturePairCache,IsFuturesPair,GetFutureSymbolByToken,futureCacheTokenKeypair_symbols.gohoặcsymbol_canonical.go: shared helpers nhưparseTokenFromSymbolByQuotePriority,selectCanonicalSymbolByQuotePrioritycache_refresh.go:refreshTradingPairCache,refreshAllCaches,cacheRefreshLoopClean up small dead-code item:
alphaCacheRefreshLooptrongmain.gohiện không còn được gọi sau khi cócacheRefreshLoop; nên remove trong cùng PR nếu vẫn giữ no-behavior-change.Acceptance:
go test ./...pass.Như vậy issue #26 vẫn là refactor naming/structure, nhưng tránh rename nửa vời khiến
trading_pairs.gotiếp tục là “god file” của market cache.