-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/#89_hunca
- Loading branch information
Showing
13 changed files
with
117 additions
and
4 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: WIP | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
wip: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: wip/action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
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