Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct typo in MP health example #8131

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions docs/mp/guides/health.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,41 +300,40 @@ package io.helidon.examples.quickstart.mp;

import java.time.Duration; // <1>
import java.util.concurrent.atomic.AtomicLong;
import jakarta.enterprise.context.ApplicationScoped;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Observes;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Started;
import org.eclipse.microprofile.health.Startup;

@Started // <2>
@Startup // <2>
@ApplicationScoped
public class GreetStartedCheck implements HealthCheck {
private final AtomicLong readyTime = new AtomicLong(0);


@Override
public HealthCheckResponse call() {
return HealthCheckResponse.named("StartedCheck") // <3>
.status(isStarted())
.withData("time", readyTime.get())
.build();
}
private final AtomicLong readyTime = new AtomicLong(0);

@Override
public HealthCheckResponse call() {
return HealthCheckResponse.named("StartedCheck") // <3>
.status(isStarted())
.withData("time", readyTime.get())
.build();
}

public void onStartUp(
@Observes @Initialized(ApplicationScoped.class) Object init) {
readyTime.set(System.currentTimeMillis()); // <4>
}
public void onStartUp(
@Observes @Initialized(ApplicationScoped.class) Object init) {
readyTime.set(System.currentTimeMillis()); // <4>
}

/**
* Become ready after 5 seconds
*
* @return true if application ready
*/
private boolean isStarted() {
return Duration.ofMillis(System.currentTimeMillis() - readyTime.get()).getSeconds() >= 8;
}
/**
* Become ready after 5 seconds
*
* @return true if application ready
*/
private boolean isStarted() {
return Duration.ofMillis(System.currentTimeMillis() - readyTime.get()).getSeconds() >= 8;
}
}
----
<1> Include additional imports.
Expand Down