This commit is contained in:
Lee 2024-04-18 14:20:55 +01:00
parent daf3770b73
commit 6e336bb879
12 changed files with 36 additions and 12 deletions

@ -0,0 +1,10 @@
package xyz.mcutils.backend.config;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@Configuration
@EnableMongoRepositories(basePackages = "xyz.mcutils.backend.repository.mongo")
public class MongoConfig {
}

@ -8,12 +8,14 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
/**
* @author Braydon
*/
@Configuration
@Log4j2(topic = "Redis")
@EnableRedisRepositories(basePackages = "xyz.mcutils.backend.repository.redis")
public class RedisConfig {
/**
* The Redis server host.

@ -1,6 +1,7 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.mongo;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.service.metric.Metric;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.service.metric.Metric;
*
* @author Braydon
*/
@EnableMongoRepositories
@Repository
public interface MetricsRepository extends MongoRepository<Metric<?>, String> { }

@ -1,5 +1,6 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.redis;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
*
* @author Braydon
*/
@EnableRedisRepositories
@Repository
public interface EndpointStatusRepository extends CrudRepository<CachedEndpointStatus, String> { }

@ -1,5 +1,6 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.redis;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
*
* @author Braydon
*/
@EnableRedisRepositories
@Repository
public interface MinecraftServerCacheRepository extends CrudRepository<CachedMinecraftServer, String> { }

@ -1,5 +1,6 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.redis;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayer;
@ -11,5 +12,6 @@ import java.util.UUID;
*
* @author Braydon
*/
@EnableRedisRepositories
@Repository
public interface PlayerCacheRepository extends CrudRepository<CachedPlayer, UUID> { }

@ -1,5 +1,6 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.redis;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayerName;
@ -13,5 +14,6 @@ import xyz.mcutils.backend.model.cache.CachedPlayerName;
*
* @author Braydon
*/
@EnableRedisRepositories
@Repository
public interface PlayerNameCacheRepository extends CrudRepository<CachedPlayerName, String> { }

@ -1,5 +1,6 @@
package xyz.mcutils.backend.repository;
package xyz.mcutils.backend.repository.redis;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart;
@ -11,5 +12,6 @@ import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart;
* player skin part by it's id.
* </p>
*/
@EnableRedisRepositories
@Repository
public interface PlayerSkinPartCacheRepository extends CrudRepository<CachedPlayerSkinPart, String> { }

@ -7,7 +7,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.mcutils.backend.common.Timer;
import xyz.mcutils.backend.repository.MetricsRepository;
import xyz.mcutils.backend.repository.mongo.MetricsRepository;
import xyz.mcutils.backend.service.metric.Metric;
import xyz.mcutils.backend.service.metric.metrics.*;
import xyz.mcutils.backend.service.metric.metrics.process.CpuUsageMetric;

@ -22,7 +22,7 @@ import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
import xyz.mcutils.backend.model.mojang.EndpointStatus;
import xyz.mcutils.backend.model.token.MojangProfileToken;
import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken;
import xyz.mcutils.backend.repository.EndpointStatusRepository;
import xyz.mcutils.backend.repository.redis.EndpointStatusRepository;
import java.io.InputStream;
import java.net.URL;

@ -21,9 +21,9 @@ import xyz.mcutils.backend.model.skin.ISkinPart;
import xyz.mcutils.backend.model.skin.Skin;
import xyz.mcutils.backend.model.token.MojangProfileToken;
import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken;
import xyz.mcutils.backend.repository.PlayerCacheRepository;
import xyz.mcutils.backend.repository.PlayerNameCacheRepository;
import xyz.mcutils.backend.repository.PlayerSkinPartCacheRepository;
import xyz.mcutils.backend.repository.redis.PlayerCacheRepository;
import xyz.mcutils.backend.repository.redis.PlayerNameCacheRepository;
import xyz.mcutils.backend.repository.redis.PlayerSkinPartCacheRepository;
import xyz.mcutils.backend.service.metric.metrics.UniquePlayerLookupsMetric;
import java.awt.image.BufferedImage;

@ -14,7 +14,7 @@ import xyz.mcutils.backend.model.dns.impl.ARecord;
import xyz.mcutils.backend.model.dns.impl.SRVRecord;
import xyz.mcutils.backend.model.server.JavaMinecraftServer;
import xyz.mcutils.backend.model.server.MinecraftServer;
import xyz.mcutils.backend.repository.MinecraftServerCacheRepository;
import xyz.mcutils.backend.repository.redis.MinecraftServerCacheRepository;
import xyz.mcutils.backend.service.metric.metrics.UniqueServerLookupsMetric;
import java.net.InetSocketAddress;