package xyz.wbsite.dbtool.web.frame.schedule;

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;

import java.time.Duration;
import java.util.concurrent.ScheduledFuture;

public abstract class RunFixRepeatTask extends RunTask {

    public abstract Duration interval();

    @Override
    public ScheduledFuture<?> schedule(ThreadPoolTaskScheduler poolTaskScheduler) {
        Assert.notNull(poolTaskScheduler, "ThreadPoolTaskScheduler must not be null");
        return poolTaskScheduler.scheduleAtFixedRate(this, interval());
    }
}
