Skip to content

Commit

Permalink
merge: #10072
Browse files Browse the repository at this point in the history
10072: Document ProcessingScheduleService.runAtFixedRate r=pihme a=korthout

## Description

<!-- Please explain the changes you made here. -->
The ProcessingScheduleService has a runAtFixedRate which is implemented in a simple way: run the task after a delay and then schedule itself. But there are some quirks around this that should be clear to the caller.

Specifically, that there is an initial delay before the task is run, **and** that due to the way it reschedules the task, time traveling only affects the currently scheduled delay.

## Related issues

<!-- Which issues are closed by this PR or are related -->

related to #10064 



Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
  • Loading branch information
zeebe-bors-camunda[bot] and korthout committed Aug 15, 2022
2 parents 9992662 + 5182043 commit 5bf6401
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public interface ProcessingScheduleService {

<T> void runOnCompletion(ActorFuture<T> precedingTask, BiConsumer<T, Throwable> followUpTask);

/**
* Schedule a task to execute at a fixed rate. After an initial delay, the task is executed. Once
* the task is executed, it is rescheduled with the same delay again.
*
* <p>Note that time-traveling in tests only affects the delay of the currently scheduled next
* task and not any of the iterations after. This is because the next task is scheduled with the
* delay counted from the new time (i.e. the time after time traveling + task execution duration +
* delay duration = scheduled time of the next task).
*
* @param delay The delay to wait initially and between each run
* @param task The task to execute at the fixed rate
*/
default void runAtFixedRate(final Duration delay, final Runnable task) {
runDelayed(
delay,
Expand Down

0 comments on commit 5bf6401

Please sign in to comment.