-
Notifications
You must be signed in to change notification settings - Fork 2
prod : yml 분리 #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
prod : yml 분리 #278
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cbde362
refactor: update application configuration files for logging and envi…
jbh010204 fe516dc
refactor: update application configuration files for logging and envi…
jbh010204 b9e1687
refactor: add default value for Discord webhook URL and prevent notif…
jbh010204 bc7d613
MOSU-267 feat: cache 적용할 도메인들 enum으로 정의
jbh010204 40f61d0
MOSU-267 feat: LocalCacheManager 구현
jbh010204 c5be4ad
MOSU-267 fix: 변수명 오타 수정
jbh010204 a0fd7db
MOSU-267 feat: 공지 도메인 캐싱 적용
jbh010204 febbe32
refactor: remove unnecessary @NotBlank annotation from PhoneNumberPat…
jbh010204 e784335
Merge branch 'develop' into refactor/mosu-267
jbh010204 50915bc
Merge pull request #269 from mosu-dev/refactor/mosu-267
jbh010204 24f6e2e
Merge branch 'feat/mosu-249' of https://github.com/mosu-dev/mosu-serv…
polyglot-k 03357a6
feat: reorganize application configuration files and add base profile
polyglot-k affed22
feat: update deployment scripts to use base environment variables and…
polyglot-k 7f0bf73
feat: implement updateInquiry method for modifying existing inquiries
polyglot-k 3dbbf21
feat: initialize DiscordNotifier with webhook URL and prevent notific…
polyglot-k da95311
feat: update DiscordNotifier to use blank check for webhook URL confi…
polyglot-k 3f0a973
feat: increase title size limit in InquiryUpdateRequest to 300 charac…
polyglot-k 08a58cd
feat: update logging configuration to specify log file path in applic…
polyglot-k 5e01c1f
Merge pull request #257 from mosu-dev/feat/mosu-249
polyglot-k 867e96d
feat: use sudo for Docker build and push commands in self-deploy YAML
polyglot-k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/life/mosu/mosuserver/application/caffeine/LocalCacheConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import com.github.benmanes.caffeine.cache.Caffeine; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import life.mosu.mosuserver.domain.caffeine.CacheGroup; | ||
| import life.mosu.mosuserver.domain.caffeine.CacheType; | ||
| import org.springframework.cache.Cache; | ||
| import org.springframework.cache.CacheManager; | ||
| import org.springframework.cache.annotation.EnableCaching; | ||
| import org.springframework.cache.caffeine.CaffeineCache; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
|
|
||
| @EnableCaching | ||
| @Configuration | ||
| public class LocalCacheConfig { | ||
|
|
||
| @Bean | ||
| public LocalCacheManager localCacheManager() { | ||
| List<Cache> caches = Arrays.stream(CacheGroup.values()) | ||
| .filter(g -> g.getCacheType() == CacheType.LOCAL | ||
| || g.getCacheType() == CacheType.COMPOSITE) | ||
| .map(g -> new CaffeineCache( | ||
| g.getCacheName(), | ||
| Caffeine.newBuilder() | ||
| .recordStats() | ||
| .expireAfterWrite(g.getExpiredAfterWrite()) | ||
| .build() | ||
| )).collect(Collectors.toList()); | ||
|
|
||
| return new LocalCacheManager(caches); | ||
| } | ||
|
|
||
| @Bean | ||
| @Primary | ||
| public CacheManager appCacheManager(LocalCacheManager localCacheManager) { | ||
| return localCacheManager; | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
src/main/java/life/mosu/mosuserver/application/caffeine/LocalCacheManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import jakarta.annotation.Nullable; | ||
| import jakarta.annotation.PostConstruct; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import org.springframework.cache.Cache; | ||
| import org.springframework.cache.CacheManager; | ||
|
|
||
| public class LocalCacheManager implements CacheManager, UpdatableCacheManager { | ||
|
|
||
| private final List<Cache> caches; | ||
| private Map<String, Cache> cacheMap = new ConcurrentHashMap<>(); | ||
| private volatile Set<String> cacheNames = Collections.emptySet(); | ||
|
|
||
| public LocalCacheManager(List<Cache> caches) { | ||
| this.caches = (caches != null) ? caches : Collections.emptyList(); | ||
| } | ||
|
|
||
| @PostConstruct | ||
| public void init() { | ||
| Set<String> cacheNamesSet = new LinkedHashSet<>(caches.size()); | ||
| Map<String, Cache> cacheMapTemp = new ConcurrentHashMap<>(16); | ||
|
|
||
| for (Cache cache : caches) { | ||
| String name = cache.getName(); | ||
| cacheNamesSet.add(name); | ||
| cacheMapTemp.put(name, cache); | ||
| } | ||
| this.cacheMap = cacheMapTemp; | ||
| this.cacheNames = cacheNamesSet; | ||
| } | ||
|
|
||
| @Override | ||
| @Nullable | ||
| public Cache getCache(String name) { | ||
| return cacheMap.get(name); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<String> getCacheNames() { | ||
| return cacheNames; | ||
| } | ||
|
|
||
| @Override | ||
| public void putIfAbsent(Cache cache, String key, Object value) { | ||
| Cache localCache = getCache(cache.getName()); | ||
| if (localCache != null) { | ||
| localCache.putIfAbsent(key, value); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/life/mosu/mosuserver/application/caffeine/UpdatableCacheManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import org.springframework.cache.Cache; | ||
|
|
||
| public interface UpdatableCacheManager { | ||
|
|
||
| void putIfAbsent(Cache cache, String key, Object value); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/life/mosu/mosuserver/domain/caffeine/CacheGroup.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package life.mosu.mosuserver.domain.caffeine; | ||
|
|
||
| import java.time.Duration; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum CacheGroup { | ||
|
|
||
| NOTICE( | ||
| "notice", | ||
| Duration.ofMinutes(10), | ||
| CacheType.LOCAL | ||
| ), | ||
|
|
||
| INQUIRY( | ||
| "inquiry", | ||
| Duration.ofMinutes(10), | ||
| CacheType.GLOBAL | ||
| ), | ||
|
|
||
| COMPOSITE_ALL( | ||
| "composite", | ||
| Duration.ofMinutes(10), | ||
| CacheType.COMPOSITE | ||
| ); | ||
|
|
||
|
|
||
| private final String cacheName; | ||
| private final Duration expiredAfterWrite; | ||
| private final CacheType cacheType; | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/main/java/life/mosu/mosuserver/domain/caffeine/CacheType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package life.mosu.mosuserver.domain.caffeine; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public enum CacheType { | ||
| LOCAL("로컬 타입만 적용"), | ||
| GLOBAL("분산 캐시만 적용"), | ||
| COMPOSITE("로컬 + 분산 캐시 모두 적용"); | ||
|
|
||
| private final String type; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explicit call to
inquiryJpaRepository.save(inquiry)is redundant here. Since theupdateInquirymethod is annotated with@Transactional, theinquiryentity fetched bygetInquiryis in a managed state. Any changes made to it (like in theinquiry.update(...)call) will be automatically detected and persisted to the database when the transaction commits. Removing this line will make the code cleaner and rely on the standard behavior of Spring Data JPA.