Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silmeth/84d6cace69dffc31e26284da9799915e to your computer and use it in GitHub Desktop.
Save silmeth/84d6cace69dffc31e26284da9799915e to your computer and use it in GitHub Desktop.
import java.time.Instant;
import com.github.kagkarlsson.scheduler.task.CompletionHandler;
import com.github.kagkarlsson.scheduler.task.ExecutionComplete;
import com.github.kagkarlsson.scheduler.task.ExecutionOperations;
import com.github.kagkarlsson.scheduler.task.Schedule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class OnCompleteRescheduleByPreviousExecution implements CompletionHandler {
private static final Logger LOG = LoggerFactory.getLogger(OnCompleteRescheduleByPreviousExecution.class);
private final Schedule schedule;
OnCompleteRescheduleByPreviousExecution(Schedule schedule) {
this.schedule = schedule;
}
@Override
public void complete(ExecutionComplete executionComplete, ExecutionOperations executionOperations) {
Instant nextExecution = schedule.getNextExecutionTime(executionComplete.getExecution().getExecutionTime());
LOG.debug("Rescheduling task {} to {}", executionComplete.getExecution().taskInstance, nextExecution);
executionOperations.reschedule(executionComplete, nextExecution);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment