2024-04-13 15:34:19 +01:00
|
|
|
package cc.fascinated.model.cache;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
import lombok.*;
|
|
|
|
import org.springframework.data.annotation.Id;
|
|
|
|
import org.springframework.data.redis.core.RedisHash;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2024-04-13 17:17:13 +01:00
|
|
|
@Setter @Getter @ToString
|
|
|
|
@NoArgsConstructor
|
2024-04-13 15:34:19 +01:00
|
|
|
@RedisHash(value = "mojangEndpointStatus", timeToLive = 60L) // 1 minute (in seconds)
|
2024-04-13 17:17:13 +01:00
|
|
|
public final class CachedEndpointStatus extends CachedResponse implements Serializable {
|
2024-04-13 15:34:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The id for this endpoint cache.
|
|
|
|
*/
|
|
|
|
@Id @NonNull @JsonIgnore
|
2024-04-13 17:17:13 +01:00
|
|
|
private String id;
|
2024-04-13 15:34:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of endpoints and their status.
|
|
|
|
*/
|
2024-04-13 17:17:13 +01:00
|
|
|
private Map<String, Status> endpoints;
|
2024-04-13 15:34:19 +01:00
|
|
|
|
2024-04-13 17:17:13 +01:00
|
|
|
public CachedEndpointStatus(@NonNull String id, Map<String, Status> endpoints) {
|
|
|
|
super(CacheInformation.defaultCache());
|
|
|
|
this.id = id;
|
|
|
|
this.endpoints = endpoints;
|
|
|
|
}
|
2024-04-13 16:46:45 +01:00
|
|
|
|
|
|
|
public enum Status {
|
2024-04-13 16:50:17 +01:00
|
|
|
/**
|
|
|
|
* The service is online and operational.
|
|
|
|
*/
|
2024-04-13 16:46:45 +01:00
|
|
|
ONLINE,
|
2024-04-13 16:50:17 +01:00
|
|
|
|
|
|
|
/**
|
2024-04-13 17:10:40 +01:00
|
|
|
* The service is online, but may be experiencing issues.
|
|
|
|
* This could be due to high load or other issues.
|
2024-04-13 16:50:17 +01:00
|
|
|
*/
|
2024-04-13 16:46:45 +01:00
|
|
|
DEGRADED,
|
2024-04-13 16:50:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The service is offline and not operational.
|
|
|
|
*/
|
2024-04-13 16:46:45 +01:00
|
|
|
OFFLINE
|
|
|
|
}
|
2024-04-13 15:34:19 +01:00
|
|
|
}
|