package com.css.simulation.resource.scheduler.infra.configuration.init;

import com.css.simulation.resource.scheduler.infra.db.redis.CustomRedisClient;
import com.css.simulation.resource.scheduler.domain.service.ProjectDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class CustomApplicationRunner implements ApplicationRunner {
    @Resource
    private ProjectDomainService projectDomainService;

    @Resource
    private CustomRedisClient customRedisClient;


    @Override
    public void run(ApplicationArguments args) {
        log.info("清空当前 Redis 库。");
        customRedisClient.flushdb();
        log.info("重置节点并行度。");
        projectDomainService.resetNodeParallelism();
    }
}
