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

org.kgrid.shelf.controller.ShelfHealthIndicator Maven / Gradle / Ivy

package org.kgrid.shelf.controller;

import org.kgrid.shelf.repository.KnowledgeObjectRepository;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class ShelfHealthIndicator implements HealthIndicator {

  ShelfHealthIndicator(KnowledgeObjectRepository shelf) {
    this.shelf = shelf;
  }

  final KnowledgeObjectRepository shelf;

  @Override
  public Health health() {
    try {
      return Health.up()
          .withDetail("numberOfKOs", shelf.findAll().size())
          .withDetail("kgrid.shelf.cdostore.url", shelf.getKoRepoLocation())
          .build();
    } catch (Exception ex) {
      return Health.down().withException(ex).build();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy