package com.smppw.modaq.infrastructure.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executor;

@Configuration
@EnableScheduling
public class AsyncSchedulerConfig implements SchedulingConfigurer {

    private final Executor asyncExecutor;

    public AsyncSchedulerConfig(@Qualifier("parseTaskScheduler") Executor asyncExecutor) {
        this.asyncExecutor = asyncExecutor;
    }

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(this.asyncExecutor);
    }
}
