-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feat/#173] 디스코드 훅 비동기 처리 풀 설정 #189
Merged
+101
−1
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fed2001
feat: ThreadPoolProperties 구현
belljun3395 e7bcf66
feat: NotSetPropertyException 구현
belljun3395 85c4272
feat: @ConfigurationPropertiesScan 추가
belljun3395 4215eb9
feat: ApiThreadPoolConfig 구현
belljun3395 f270207
feat: discord thread pool 설정 추가
belljun3395 e5f068e
refactor: WorkbookSubscriptionEventListener에 DISCORD_HOOK_EVENT_POOL 할당
belljun3395 aae043d
feat: test에 추가된 설정 반영
belljun3395 8532212
Merge branch 'main' into feat/#173_belljun3395
belljun3395 eb653b5
Merge branch 'main' into feat/#173_belljun3395
belljun3395 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 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
39 changes: 39 additions & 0 deletions
39
api/src/main/kotlin/com/few/api/config/ApiThreadPoolConfig.kt
This file contains 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,39 @@ | ||
package com.few.api.config | ||
|
||
import com.few.api.config.properties.ThreadPoolProperties | ||
import org.apache.juli.logging.LogFactory | ||
import org.springframework.boot.context.properties.ConfigurationProperties | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor | ||
|
||
@Configuration | ||
class ApiThreadPoolConfig { | ||
|
||
private val log = LogFactory.getLog(ApiThreadPoolConfig::class.java) | ||
|
||
companion object { | ||
const val DISCORD_HOOK_EVENT_POOL = "discord-task-" | ||
} | ||
|
||
@Bean | ||
@ConfigurationProperties(prefix = "discord.thread-pool") | ||
fun disCordThreadPoolProperties(): ThreadPoolProperties { | ||
return ThreadPoolProperties() | ||
} | ||
|
||
@Bean(DISCORD_HOOK_EVENT_POOL) | ||
fun discordHookThreadPool() = ThreadPoolTaskExecutor().apply { | ||
val properties = disCordThreadPoolProperties() | ||
corePoolSize = properties.getCorePoolSize() | ||
maxPoolSize = properties.getMaxPoolSize() | ||
queueCapacity = properties.getQueueCapacity() | ||
setWaitForTasksToCompleteOnShutdown(properties.getWaitForTasksToCompleteOnShutdown()) | ||
setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds()) | ||
setThreadNamePrefix("discordHookThreadPool-") | ||
setRejectedExecutionHandler { r, _ -> | ||
log.warn("Discord Hook Event Task Rejected: $r") | ||
} | ||
initialize() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
api/src/main/kotlin/com/few/api/config/properties/ThreadPoolProperties.kt
This file contains 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,31 @@ | ||
package com.few.api.config.properties | ||
|
||
import com.few.api.exception.properties.NotSetPropertyException | ||
|
||
data class ThreadPoolProperties( | ||
var corePoolSize: Int? = null, | ||
var maxPoolSize: Int? = null, | ||
var queueCapacity: Int? = null, | ||
var waitForTasksToCompleteOnShutdown: Boolean? = null, | ||
var awaitTerminationSeconds: Int? = null | ||
) { | ||
fun getCorePoolSize(): Int { | ||
return corePoolSize ?: throw NotSetPropertyException("core pool size") | ||
} | ||
|
||
fun getMaxPoolSize(): Int { | ||
return maxPoolSize ?: throw NotSetPropertyException("max pool size") | ||
} | ||
|
||
fun getQueueCapacity(): Int { | ||
return queueCapacity ?: throw NotSetPropertyException("queue capacity") | ||
} | ||
|
||
fun getWaitForTasksToCompleteOnShutdown(): Boolean { | ||
return waitForTasksToCompleteOnShutdown ?: throw NotSetPropertyException("waitForTasksToCompleteOnShutdown") | ||
} | ||
|
||
fun getAwaitTerminationSeconds(): Int { | ||
return awaitTerminationSeconds ?: throw NotSetPropertyException("awaitTerminationSeconds") | ||
} | ||
} |
This file contains 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
3 changes: 3 additions & 0 deletions
3
api/src/main/kotlin/com/few/api/exception/properties/NotSetPropertyException.kt
This file contains 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,3 @@ | ||
package com.few.api.exception.properties | ||
|
||
class NotSetPropertyException(property: String) : RuntimeException("$property is not set") |
This file contains 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 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 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.
굳굳 좋습니다. 혹시 몰라서 설정 정보 메모용으로 남겨둘께요