ru.tinkoff.kora.scheduling.jdk.RunOnceJob Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scheduling-jdk Show documentation
Show all versions of scheduling-jdk Show documentation
Kora scheduling-jdk module
package ru.tinkoff.kora.scheduling.jdk;
import ru.tinkoff.kora.scheduling.common.telemetry.SchedulingTelemetry;
import java.time.Duration;
import java.util.Objects;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public final class RunOnceJob extends AbstractJob {
private final Duration delay;
public RunOnceJob(SchedulingTelemetry schedulingTelemetry, JdkSchedulingExecutor service, Runnable command, Duration delay) {
super(schedulingTelemetry, service, command);
this.delay = Objects.requireNonNull(delay);
}
@Override
protected ScheduledFuture> schedule(JdkSchedulingExecutor service, Runnable command) {
var delay = this.delay.toMillis();
return service.schedule(command, delay, TimeUnit.MILLISECONDS);
}
}