fix(naver-fetch): realestate base :18800 + 동별 ingest + 180s no-retry
This commit is contained in:
@@ -46,20 +46,22 @@
|
||||
state.state = "fetching"
|
||||
await naver.acquire_token() # Playwright 1회 (사이클당)
|
||||
tg = await nas.get_targets() # {dongs:[{dong,cortar_no}], deal_types, page_limit}
|
||||
batches = []
|
||||
for d in tg.dongs: # 동 단위 try/except 격리
|
||||
for d in tg.dongs: # 동 단위 try/except 격리 (fetch/ingest 각각)
|
||||
articles = []
|
||||
for page in 1..tg.page_limit:
|
||||
resp = await naver.fetch_articles(d.cortar_no, page) # httpx GET
|
||||
articles += resp.get("articleList", [])
|
||||
if not resp.get("isMoreData"): break
|
||||
batches.append({"dong": d.dong, "articles": articles})
|
||||
r = await nas.post_ingest(fetched_at=iso_utc_now, batches=batches) # {received,new,matched}
|
||||
state.listings_pushed += sum(len(b["articles"]) for b in batches)
|
||||
# ⚠️ 동별로 즉시 ingest — 전체 batch를 한 POST로 보내면 NAS 동기 처리(매물 수 비례)가
|
||||
# >180s 타임아웃. 동 단위(각 수십건)로 쪼개 각 POST가 timeout 내 완료 + 부분 실패 격리.
|
||||
r = await nas.post_ingest(fetched_at=iso_utc_now, batches=[{"dong": d.dong, "articles": articles}])
|
||||
state.listings_pushed += len(articles) # {received,new,matched}
|
||||
state.last_fetch_at = epoch_now
|
||||
state.state = "idle"
|
||||
```
|
||||
|
||||
> ⚠️ **ingest 분할**: 스펙은 batches(복수)를 한 POST로 예시하지만, 첫 실행 대량(6동×~40건)이 NAS에서 >180s 걸려 타임아웃 → **동별 1 POST**로 분할(batches 리스트 계약 호환, 각 POST는 batches 1개). nas_client의 ingest는 timeout 180s·재시도 없음(재전송 시 NAS 중복 알림 방지). BE에 분할 통지 필요.
|
||||
|
||||
> ⚠️ **시간 포맷 2종**: ingest `fetched_at`은 **ISO UTC 문자열**(스펙 §4 ingest 스키마, 예 `2026-07-09T05:44:23Z`), heartbeat `ts`/`last_fetch_at`은 **epoch 정수**(스펙 §4.4). 혼동 주의.
|
||||
|
||||
`heartbeat_loop`(별도 15초)이 `FetchState`를 읽어 §4.4 페이로드 발신.
|
||||
@@ -101,7 +103,7 @@ state.state = "idle"
|
||||
|
||||
| env | 기본값 | 용도 |
|
||||
|-----|--------|------|
|
||||
| `NAS_BASE_URL` | `http://192.168.45.54:18500` | targets/ingest |
|
||||
| `NAS_BASE_URL` (compose: `NAVER_NAS_BASE_URL`) | `http://192.168.45.54:18800` | **realestate-lab 직결** targets/ingest (stock :18500 아님) |
|
||||
| `INTERNAL_API_KEY` | (필수) | `X-Internal-Key` (render 워커 공유키) |
|
||||
| `REDIS_URL` | `redis://192.168.45.54:6379` | heartbeat |
|
||||
| `FETCH_INTERVAL_HOURS` | `2.5` | fetch 주기 |
|
||||
|
||||
Reference in New Issue
Block a user