diff --git a/infrastructure/build.gradle.kts b/infrastructure/build.gradle.kts index 6ce66765..57547d1c 100644 --- a/infrastructure/build.gradle.kts +++ b/infrastructure/build.gradle.kts @@ -27,12 +27,12 @@ dependencies { implementation("org.springframework.cloud:spring-cloud-starter-aws:_") // redis - implementation("org.springframework.boot:spring-boot-starter-data-redis:_") - implementation("org.redisson:redisson-spring-boot-starter:_") - implementation("it.ozimov:embedded-redis:_") { - exclude(group = "org.slf4j", module = "slf4j-simple") - because("테스트 환경에서 사용할 embedded-redis") - } +// implementation("org.springframework.boot:spring-boot-starter-data-redis:_") +// implementation("org.redisson:redisson-spring-boot-starter:_") +// implementation("it.ozimov:embedded-redis:_") { +// exclude(group = "org.slf4j", module = "slf4j-simple") +// because("테스트 환경에서 사용할 embedded-redis") +// } // webflux (HTTP 요청에 사용) implementation("org.springframework.boot:spring-boot-starter-webflux") diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/common/aop/DistributedLockAop.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/common/aop/DistributedLockAop.java index 4d0b1f37..13a52d2d 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/common/aop/DistributedLockAop.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/common/aop/DistributedLockAop.java @@ -1,69 +1,69 @@ -package org.depromeet.spot.infrastructure.common.aop; - -import java.lang.reflect.Method; -import java.util.Arrays; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.reflect.MethodSignature; -import org.depromeet.spot.common.annotation.DistributedLock; -import org.depromeet.spot.infrastructure.common.util.SpringELParser; -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Aspect +// package org.depromeet.spot.infrastructure.common.aop; +// +// import java.lang.reflect.Method; +// import java.util.Arrays; +// +// import org.aspectj.lang.ProceedingJoinPoint; +// import org.aspectj.lang.annotation.Around; +// import org.aspectj.lang.annotation.Aspect; +// import org.aspectj.lang.reflect.MethodSignature; +// import org.depromeet.spot.common.annotation.DistributedLock; +// import org.depromeet.spot.infrastructure.common.util.SpringELParser; +// import org.redisson.api.RLock; +// import org.redisson.api.RedissonClient; +// +// import lombok.RequiredArgsConstructor; +// import lombok.extern.slf4j.Slf4j; +// +// @Slf4j +// @Aspect // @Component -@RequiredArgsConstructor -public class DistributedLockAop { - - private final RedissonClient redissonClient; - private final TransactionAop aopForTransaction; - - private static final String REDISSON_LOCK_PREFIX = "LOCK:"; - - @Around("@annotation(org.depromeet.spot.common.annotation.DistributedLock)") - public Object lock(ProceedingJoinPoint joinPoint) throws Throwable { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); - DistributedLock distributedLock = method.getAnnotation(DistributedLock.class); - - String lockKey = generateLockKey(signature, joinPoint.getArgs(), distributedLock); - RLock rLock = redissonClient.getLock(lockKey); - - try { - if (!acquireLock(rLock, distributedLock)) { - return false; - } - return aopForTransaction.proceed(joinPoint); - } catch (InterruptedException e) { - log.error(Arrays.toString(e.getStackTrace())); - throw e; - } finally { - releaseLock(rLock); - } - } - - private String generateLockKey( - MethodSignature signature, Object[] args, DistributedLock distributeLock) { - return REDISSON_LOCK_PREFIX - + SpringELParser.getDynamicValue( - signature.getParameterNames(), args, distributeLock.key()); - } - - private boolean acquireLock(RLock rLock, DistributedLock distributeLock) - throws InterruptedException { - return rLock.tryLock( - distributeLock.waitTime(), distributeLock.leaseTime(), distributeLock.timeUnit()); - } - - private void releaseLock(RLock rLock) { - if (rLock != null && rLock.isHeldByCurrentThread()) { - rLock.unlock(); - } - } -} +// @RequiredArgsConstructor +// public class DistributedLockAop { +// +// private final RedissonClient redissonClient; +// private final TransactionAop aopForTransaction; +// +// private static final String REDISSON_LOCK_PREFIX = "LOCK:"; +// +// @Around("@annotation(org.depromeet.spot.common.annotation.DistributedLock)") +// public Object lock(ProceedingJoinPoint joinPoint) throws Throwable { +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); +// Method method = signature.getMethod(); +// DistributedLock distributedLock = method.getAnnotation(DistributedLock.class); +// +// String lockKey = generateLockKey(signature, joinPoint.getArgs(), distributedLock); +// RLock rLock = redissonClient.getLock(lockKey); +// +// try { +// if (!acquireLock(rLock, distributedLock)) { +// return false; +// } +// return aopForTransaction.proceed(joinPoint); +// } catch (InterruptedException e) { +// log.error(Arrays.toString(e.getStackTrace())); +// throw e; +// } finally { +// releaseLock(rLock); +// } +// } +// +// private String generateLockKey( +// MethodSignature signature, Object[] args, DistributedLock distributeLock) { +// return REDISSON_LOCK_PREFIX +// + SpringELParser.getDynamicValue( +// signature.getParameterNames(), args, distributeLock.key()); +// } +// +// private boolean acquireLock(RLock rLock, DistributedLock distributeLock) +// throws InterruptedException { +// return rLock.tryLock( +// distributeLock.waitTime(), distributeLock.leaseTime(), distributeLock.timeUnit()); +// } +// +// private void releaseLock(RLock rLock) { +// if (rLock != null && rLock.isHeldByCurrentThread()) { +// rLock.unlock(); +// } +// } +// } diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/redis/RedisProperties.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/redis/RedisProperties.java index 4d912c43..dc1f2864 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/redis/RedisProperties.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/redis/RedisProperties.java @@ -1,6 +1,6 @@ -package org.depromeet.spot.infrastructure.redis; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties(prefix = "aws.redis") -public record RedisProperties(String host, int port) {} +// package org.depromeet.spot.infrastructure.redis; +// +// import org.springframework.boot.context.properties.ConfigurationProperties; +// +// @ConfigurationProperties(prefix = "aws.redis") +// public record RedisProperties(String host, int port) {} diff --git a/infrastructure/src/main/resources/application-aws.yaml b/infrastructure/src/main/resources/application-aws.yaml index 05bb1238..73f57d67 100644 --- a/infrastructure/src/main/resources/application-aws.yaml +++ b/infrastructure/src/main/resources/application-aws.yaml @@ -3,7 +3,4 @@ aws: accessKey: ${AWS_ACCESS_KEY} secretKey: ${AWS_SECRET_KEY} bucketName: ${S3_BUCKET_NAME} - basicProfileImageUrl: ${S3_BASIC_PROFILE_IMAGE_URL} - redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} \ No newline at end of file + basicProfileImageUrl: ${S3_BASIC_PROFILE_IMAGE_URL} \ No newline at end of file diff --git a/versions.properties b/versions.properties index 53821993..b820f57b 100644 --- a/versions.properties +++ b/versions.properties @@ -23,7 +23,7 @@ version.junit=5.9.1 version.org.projectlombok..lombok=1.18.30 -version.org.redisson..redisson-spring-boot-starter=3.34.1 +#version.org.redisson..redisson-spring-boot-starter=3.34.1 version.org.springframework.boot..spring-boot-starter-test=3.0.1 @@ -39,9 +39,9 @@ version.com.querydsl..querydsl-jpa=5.0.0 version.org.springframework.cloud..spring-cloud-starter-aws=2.2.6.RELEASE -version.org.springframework.boot..spring-boot-starter-data-redis=3.3.0 +#version.org.springframework.boot..spring-boot-starter-data-redis=3.3.0 -version.org.redission..redisson-spring-boot-starter=3.26.0 +#version.org.redission..redisson-spring-boot-starter=3.26.0 version.org.springframework.boot..spring-boot-configuration-processor=3.0.1 @@ -61,7 +61,7 @@ version.io.micrometer..micrometer-registry-prometheus=1.12.4 version.com.github.ben-manes.caffeine..caffeine=3.1.8 -version.it.ozimov..embedded-redis=0.7.3 +#version.it.ozimov..embedded-redis=0.7.3 version.org.testcontainers..testcontainers=1.20.1