From 28955254129963b8b7948e035625d572a67f7ae0 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 13 Apr 2024 16:50:17 +0100 Subject: [PATCH] degraded status if response time is more than 1 second --- .../model/cache/CachedEndpointStatus.java | 14 ++++++++++++++ .../java/cc/fascinated/service/MojangService.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/fascinated/model/cache/CachedEndpointStatus.java b/src/main/java/cc/fascinated/model/cache/CachedEndpointStatus.java index 3e8f224..c00c61b 100644 --- a/src/main/java/cc/fascinated/model/cache/CachedEndpointStatus.java +++ b/src/main/java/cc/fascinated/model/cache/CachedEndpointStatus.java @@ -30,8 +30,22 @@ public final class CachedEndpointStatus implements Serializable { private long cached; public enum Status { + /** + * The service is online and operational. + */ ONLINE, + + /** + * The service is degraded and may not be fully operational. + *

+ * This could be due to high load or other issues. + *

+ */ DEGRADED, + + /** + * The service is offline and not operational. + */ OFFLINE } } \ No newline at end of file diff --git a/src/main/java/cc/fascinated/service/MojangService.java b/src/main/java/cc/fascinated/service/MojangService.java index 6324e32..518fab8 100644 --- a/src/main/java/cc/fascinated/service/MojangService.java +++ b/src/main/java/cc/fascinated/service/MojangService.java @@ -204,7 +204,7 @@ public class MojangService { if (endpoint.getAllowedStatuses().contains(response.getStatusCode())) { online = true; } - if (online && System.currentTimeMillis() - start > 500) { // If the response took longer than 500ms + if (online && System.currentTimeMillis() - start > 1000) { // If the response took longer than 1 second return CachedEndpointStatus.Status.DEGRADED; } return online ? CachedEndpointStatus.Status.ONLINE : CachedEndpointStatus.Status.OFFLINE;