Skip to content

Commit

Permalink
feat: re-implementation of /api/v1/status (#114)
Browse files Browse the repository at this point in the history
* chore: fix missing author

* feat: use c3p0 connection pool in production

* feat: health_check_records table

* feat: add gpg sign to action users

* feat: add gpg sign to action users

* feat: db updates, concurrent and orm example

* feat: use timestamp to verify checks

* ci: use automatically generated token

* lint: JackRoutes

* feat: valkey cache manager

* fix: middleware conflict

* ci: resolve conflict from upstream

* fix: remove com.zephyr.caches

* fix: db query leaking

* fix: fix concurrent on /healthz route

* feat: fix db connection leaking

* feat: re-implementation of /api/v1/status
  • Loading branch information
binaryYuki authored Feb 3, 2025
1 parent fccb67e commit 3704ec2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/Zephyr/YukiRoutes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import io.vertx.ext.web.RoutingContext;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import jakarta.persistence.EntityManagerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author binaryYuki
*/
public class YukiRoutes {

private static final Logger log = LoggerFactory.getLogger(YukiRoutes.class);
private final Vertx vertx;

// 构造函数,接收 Vert.x 实例
Expand Down Expand Up @@ -47,6 +51,14 @@ private void handleHealthz(RoutingContext ctx) {

// 处理 "/api/v1/status" 路径的逻辑
private void handleStatus(RoutingContext ctx) {
EntityManagerFactory entityManager = dbHelper.getEntityManagerFactory();
try {
entityManager.createEntityManager().createNativeQuery("SELECT 1").getSingleResult();
} catch (Exception e) {
ctx.fail(500);
throw new RuntimeException(e);
}
log.info("app's status is good!"+System.currentTimeMillis());
JsonObject response = new JsonObject()
.put("status", "ok")
.put("message", "Austin's status is good!")
Expand Down

0 comments on commit 3704ec2

Please sign in to comment.