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.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
/** /**
* @author Braydon * @author Braydon
*/ */
@Configuration @Configuration
@Log4j2(topic = "Redis") @Log4j2(topic = "Redis")
@EnableRedisRepositories(basePackages = "xyz.mcutils.backend.repository.redis")
public class RedisConfig { public class RedisConfig {
/** /**
* The Redis server host. * 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.MongoRepository;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.service.metric.Metric; import xyz.mcutils.backend.service.metric.Metric;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.service.metric.Metric;
* *
* @author Braydon * @author Braydon
*/ */
@EnableMongoRepositories
@Repository @Repository
public interface MetricsRepository extends MongoRepository<Metric<?>, String> { } 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedEndpointStatus; import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
* *
* @author Braydon * @author Braydon
*/ */
@EnableRedisRepositories
@Repository @Repository
public interface EndpointStatusRepository extends CrudRepository<CachedEndpointStatus, String> { } 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedMinecraftServer; import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
@ -9,5 +10,6 @@ import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
* *
* @author Braydon * @author Braydon
*/ */
@EnableRedisRepositories
@Repository @Repository
public interface MinecraftServerCacheRepository extends CrudRepository<CachedMinecraftServer, String> { } 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayer; import xyz.mcutils.backend.model.cache.CachedPlayer;
@ -11,5 +12,6 @@ import java.util.UUID;
* *
* @author Braydon * @author Braydon
*/ */
@EnableRedisRepositories
@Repository @Repository
public interface PlayerCacheRepository extends CrudRepository<CachedPlayer, UUID> { } 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayerName; import xyz.mcutils.backend.model.cache.CachedPlayerName;
@ -13,5 +14,6 @@ import xyz.mcutils.backend.model.cache.CachedPlayerName;
* *
* @author Braydon * @author Braydon
*/ */
@EnableRedisRepositories
@Repository @Repository
public interface PlayerNameCacheRepository extends CrudRepository<CachedPlayerName, String> { } 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.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart; 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. * player skin part by it's id.
* </p> * </p>
*/ */
@EnableRedisRepositories
@Repository @Repository
public interface PlayerSkinPartCacheRepository extends CrudRepository<CachedPlayerSkinPart, String> { } 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import xyz.mcutils.backend.common.Timer; 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.Metric;
import xyz.mcutils.backend.service.metric.metrics.*; import xyz.mcutils.backend.service.metric.metrics.*;
import xyz.mcutils.backend.service.metric.metrics.process.CpuUsageMetric; 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.mojang.EndpointStatus;
import xyz.mcutils.backend.model.token.MojangProfileToken; import xyz.mcutils.backend.model.token.MojangProfileToken;
import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken; 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.io.InputStream;
import java.net.URL; 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.skin.Skin;
import xyz.mcutils.backend.model.token.MojangProfileToken; import xyz.mcutils.backend.model.token.MojangProfileToken;
import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken; import xyz.mcutils.backend.model.token.MojangUsernameToUuidToken;
import xyz.mcutils.backend.repository.PlayerCacheRepository; import xyz.mcutils.backend.repository.redis.PlayerCacheRepository;
import xyz.mcutils.backend.repository.PlayerNameCacheRepository; import xyz.mcutils.backend.repository.redis.PlayerNameCacheRepository;
import xyz.mcutils.backend.repository.PlayerSkinPartCacheRepository; import xyz.mcutils.backend.repository.redis.PlayerSkinPartCacheRepository;
import xyz.mcutils.backend.service.metric.metrics.UniquePlayerLookupsMetric; import xyz.mcutils.backend.service.metric.metrics.UniquePlayerLookupsMetric;
import java.awt.image.BufferedImage; 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.dns.impl.SRVRecord;
import xyz.mcutils.backend.model.server.JavaMinecraftServer; import xyz.mcutils.backend.model.server.JavaMinecraftServer;
import xyz.mcutils.backend.model.server.MinecraftServer; 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 xyz.mcutils.backend.service.metric.metrics.UniqueServerLookupsMetric;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;