package ru.ibs.socrates.confexporter.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.availability.AvailabilityChangeEvent;
import org.springframework.boot.availability.LivenessState;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class LivenessEventListener {

  @EventListener
  public void onEvent(AvailabilityChangeEvent<LivenessState> event) {
    switch (event.getState()) {
      case BROKEN:
        log.info("Liveness BROKEN event: {}", event);
        break;
      case CORRECT:
        log.info("Liveness CORRECT event: {}", event);
        break;
      default:
        break;
    }
  }
}
