Files
Backend/src/main/java/cc/fascinated/model/cache/CachedEndpointStatus.java

51 lines
1.3 KiB
Java
Raw Normal View History

2024-04-13 15:34:19 +01:00
package cc.fascinated.model.cache;
2024-04-13 18:02:46 +01:00
import cc.fascinated.common.CacheInformation;
2024-04-13 15:34:19 +01:00
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 18:02:46 +01:00
public 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;
}
public enum Status {
/**
* The service is online and operational.
*/
ONLINE,
/**
* The service is online, but may be experiencing issues.
* This could be due to high load or other issues.
*/
DEGRADED,
/**
* The service is offline and not operational.
*/
OFFLINE
}
2024-04-13 15:34:19 +01:00
}