package com.ycwl.basic.controller.monitor;

import com.ycwl.basic.integration.kafka.scheduler.AccountFaceSchedulerManager;
import com.ycwl.basic.utils.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 人脸识别监控接口
 * 提供调度器状态查询功能
 */
@RestController
@RequestMapping("/api/monitor/face-recognition")
@RequiredArgsConstructor
public class FaceRecognitionMonitorController {

    private final AccountFaceSchedulerManager schedulerManager;

    /**
     * 获取所有账号的调度器统计信息
     * <p>
     * 示例返回:
     * {
     *   "LTAI5xxx": {
     *     "accountKey": "LTAI5xxx",
     *     "cloudType": "ALI",
     *     "activeThreads": 3,
     *     "executorQueueSize": 12,
     *     "schedulerQueueSize": 45
     *   },
     *   "245xxx": {
     *     "accountKey": "245xxx",
     *     "cloudType": "BAIDU",
     *     "activeThreads": 8,
     *     "executorQueueSize": 5,
     *     "schedulerQueueSize": 20
     *   }
     * }
     *
     * @return 所有账号的调度器状态
     */
    @GetMapping("/schedulers")
    public ApiResponse<Map<String, AccountFaceSchedulerManager.AccountSchedulerStats>> getAllSchedulerStats() {
        return ApiResponse.success(schedulerManager.getAllStats());
    }
}
