package com.goldenchart.trading.pipeline;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 종목별 마지막 체결 수신 시각 — WebSocket 헬스 모니터용.
 */
@Component
public class TickActivityTracker {

    private final Map<String, Long> lastTickMs = new ConcurrentHashMap<>();

    public void record(String market) {
        lastTickMs.put(market, System.currentTimeMillis());
    }

    public long lastTickMs(String market) {
        return lastTickMs.getOrDefault(market, 0L);
    }

    public Map<String, Long> snapshot() {
        return Map.copyOf(lastTickMs);
    }
}
