4.0 KiB
4.0 KiB
MoexClientService Split — Plan
Подход
Полный сплит по доменам (ADR-020). Один коммит — миграция всех файлов одновременно.
Архитектура
modules/moex-client/
├── moex-http.client.ts # Инфраструктура: axios, PQueue, circuit breaker
├── moex-securities.client.ts # searchSecurities(), getSecurityDescription()
├── moex-market-data.client.ts # getShareMarketData(), getShareMarketDataBatch(),
│ # getBondData(), getBondMarketData(), getBondPositionDataBatch()
├── moex-candles.client.ts # getCandles()
├── moex-history.client.ts # getHistory(), getBondHistory()
├── moex-dividends.client.ts # getDividends()
├── moex-client.types.ts # (unchanged)
├── moex-client.module.ts # providers: все клиенты, exports: доменные клиенты, не @Global()
├── moex-client.service.spec.ts # → moex-http.client.spec.ts
└── moex-client.service.integration.spec.ts # → интеграционные тесты
Data Flow
Consumer Service
↓ (DI)
Domain Client (MoexSecuritiesClient | MoexMarketDataClient | etc.)
↓ (DI)
MoexHttpClient (request + extractTable)
↓
MOEX ISS API
MoexHttpClient — не экспортируется из модуля, только доменные клиенты его видят.
Consumer Updates
| Модуль | Было | Стало |
|---|---|---|
shares/shares.module.ts |
— | imports: [MoexClientModule] |
shares/shares.service.ts |
moexClient: MoexClientService |
moexSecurities: MoexSecuritiesClient, moexMarketData: MoexMarketDataClient |
bonds/bonds.module.ts |
— | imports: [MoexClientModule] |
bonds/bonds.service.ts |
moexClient: MoexClientService |
moexMarketData: MoexMarketDataClient, moexHistory: MoexHistoryClient |
candles/candles.module.ts |
— | imports: [MoexClientModule] |
candles/candles.service.ts |
moexClient: MoexClientService |
moexCandles: MoexCandlesClient |
securities/securities.module.ts |
— | imports: [MoexClientModule] |
securities/securities.service.ts |
moexClient: MoexClientService |
moexSecurities: MoexSecuritiesClient, moexMarketData: MoexMarketDataClient |
securities/screener.service.ts |
moexClient: MoexClientService |
moexMarketData: MoexMarketDataClient |
portfolio/portfolio.module.ts |
— | imports: [MoexClientModule] |
portfolio/portfolio.service.ts |
moexClient: MoexClientService |
moexSecurities: MoexSecuritiesClient, moexMarketData: MoexMarketDataClient, moexDividends: MoexDividendsClient |
tbank/tbank.module.ts |
imports: [MoexClientModule] |
(unchanged) |
tbank/.../broker-events.service.ts |
moexClient: MoexClientService |
moexDividends: MoexDividendsClient, moexMarketData: MoexMarketDataClient |
Migration Order
- Создать
MoexHttpClient— перенести инфраструктуру изMoexClientService - Создать
MoexSecuritiesClient— перенести 2 метода - Создать
MoexMarketDataClient— перенести 5 методов - Создать
MoexCandlesClient— перенести 1 метод - Создать
MoexHistoryClient— перенести 2 метода - Создать
MoexDividendsClient— перенести 1 метод - Обновить
MoexClientModule— убрать@Global(), новые providers/exports - Обновить всех потребителей (модули + сервисы + тесты)
- Удалить старый
MoexClientService npm run build && npm run test
Testing Strategy
MoexHttpClient— unit-тесты на circuit breaker, rate limiter, request- Каждый доменный клиент — unit-тесты с mocked
MoexHttpClient - Существующие тесты потребителей — обновить DI-моки