package com.home4j;

import com.home4j.service.UserService;
import jakarta.inject.Inject;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;
import org.eclipse.microprofile.health.Readiness;

/**
 * Home4j Health Check
 */
@Liveness
@Readiness
public class MyLivenessCheck implements HealthCheck {

    @Inject
    UserService userService;

    @Override
    public HealthCheckResponse call() {
        return HealthCheckResponse.named("home4j")
                .up()
                .withData("version", "0.1.0")
                .withData("users", userService.getUserCount())
                .build();
    }
}