Skip to content

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Oct 16, 2025

No description provided.

ScheduledFuture<?> scheduledFuture = podReadySelfShutDownScheduler.scheduleWithFixedDelay(() -> {

if (podReadyCompletableFuture.isDone()) {
LOG.info(() -> "pod readiness is known, not running another cycle");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here goes like this:

  • there is a CachedSingleThreadScheduler podReadySelfShutDownScheduler that will shut down itself when there are no tasks for it to run
  • we issue the call podReadySelfShutDownScheduler::podReady that returns a CompletableFuture
  • the podReady method schedules the podReadySupplier to run and returns a ScheduledFuture
  • When ScheduledFuture is either done or fails, we complete the CompletableFuture with that status. For example:
if (podReadySupplier.getAsBoolean()) {
    podReadyCompletableFuture.complete(null);
}
  • the attachShutDownHook makes sure that if the resulting CompletableFuture is completed, we also stop the ScheduledFuture, thus shutting down the executor; thus not leaving anything hanging.

Signed-off-by: wind57 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants