All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.transferwise.common.gracefulshutdown.strategies.GracefulShutdownHealthStrategy Maven / Gradle / Ivy

There is a newer version: 2.14.5
Show newest version
package com.transferwise.common.gracefulshutdown.strategies;

import com.transferwise.common.gracefulshutdown.GracefulShutdownStrategy;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class GracefulShutdownHealthStrategy implements GracefulShutdownStrategy {

  @Getter
  private volatile boolean shutdownInProgress;

  @Getter
  private volatile boolean startupInProgress = true;

  @Override
  public void applicationStarted() {
    log.info("Considering Service as fully started. Starting to broadcast UP state.");
    startupInProgress = false;
    shutdownInProgress = false;
  }

  @Override
  public void prepareForShutdown() {
    log.info("Switching to shutdown mode. Starting to broadcast OUT_OF_SERVICE state.");
    shutdownInProgress = true;
  }

  @Override
  public boolean canShutdown() {
    return true;
  }

  @Override
  public boolean isReady() {
    return !startupInProgress;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy