Skip to content

Commit 9467ec2

Browse files
author
Tomáš Kraus
authored
Marked deprecated HealthCheck API. Modified examples to use current HealthCheck API properly. (helidon-io#2656)
Signed-off-by: Tomas Kraus <Tomas.Kraus@oracle.com>
1 parent ce5b470 commit 9467ec2

21 files changed

Lines changed: 823 additions & 141 deletions

File tree

archetypes/database-se/src/main/resources/src/main/java/__pkg__/Main.java.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class Main {
8686
8787
// Support for health
8888
HealthSupport health = HealthSupport.builder()
89-
.addLiveness(DbClientHealthCheck.create(dbClient))
89+
.addLiveness(DbClientHealthCheck.create(dbClient, dbConfig.get("health-check")))
9090
.build();
9191
9292
// Initialize database schema

archetypes/database-se/src/main/resources/src/main/resources/application.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ db:
2121
services:
2222
metrics:
2323
- type: METER
24+
health-check:
25+
type: "dml"
26+
statementName: "ping"
2427
statements:
2528
# Ping statement
2629
ping: "SET @HELIDON_PING=0"

dbclient/dbclient/src/main/java/io/helidon/dbclient/DbClient.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import java.util.function.Supplier;
2323

2424
import io.helidon.common.mapper.MapperManager;
25-
import io.helidon.common.reactive.Single;
2625
import io.helidon.common.reactive.Subscribable;
2726
import io.helidon.common.serviceloader.HelidonServiceLoader;
2827
import io.helidon.config.Config;
@@ -57,20 +56,6 @@ public interface DbClient {
5756
*/
5857
<U, T extends Subscribable<U>> T execute(Function<DbExecute, T> executor);
5958

60-
/**
61-
* Name of the named statement used in database health checks.
62-
*/
63-
String PING_STATEMENT_NAME = "ping";
64-
65-
/**
66-
* Pings the database, completes when DB is up and ready, completes exceptionally if not.
67-
* Executes simple SQL query defined as {@code db.statements.ping} configuration property.
68-
*
69-
* @return stage that completes when the ping finished
70-
* @deprecated Use {@code io.helidon.dbclient.health.DbClientHealthCheck} instead.
71-
*/
72-
Single<Void> ping();
73-
7459
/**
7560
* Type of this database provider (such as jdbc:mysql, mongoDB etc.).
7661
*

dbclient/health/pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -39,5 +39,20 @@
3939
<groupId>io.helidon.health</groupId>
4040
<artifactId>helidon-health</artifactId>
4141
</dependency>
42+
<dependency>
43+
<groupId>io.helidon.config</groupId>
44+
<artifactId>helidon-config-yaml</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-api</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.hamcrest</groupId>
54+
<artifactId>hamcrest-all</artifactId>
55+
<scope>test</scope>
56+
</dependency>
4257
</dependencies>
4358
</project>

0 commit comments

Comments
 (0)