package com.lingniu.ingest.sink.kafka;

import com.lingniu.ingest.api.event.VehicleEvent;

/**
 * 事件 → Kafka topic 路由。集中管理避免散落。
 */
public final class TopicRouter {

    private final KafkaSinkProperties.Topics topics;

    public TopicRouter(KafkaSinkProperties.Topics topics) {
        this.topics = topics;
    }

    public String route(VehicleEvent event) {
        return switch (event) {
            case VehicleEvent.Realtime _   -> topics.getRealtime();
            case VehicleEvent.Location _   -> topics.getLocation();
            case VehicleEvent.Alarm _      -> topics.getAlarm();
            case VehicleEvent.Login _,
                 VehicleEvent.Logout _,
                 VehicleEvent.Heartbeat _  -> topics.getSession();
            case VehicleEvent.MediaMeta _  -> topics.getMediaMeta();
            case VehicleEvent.Passthrough _ -> topics.getAlarm();
            case VehicleEvent.RawArchive _ -> topics.getRawArchive();
        };
    }
}
