Skip to content

Commit

Permalink
chore: pinterest ktlint 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Dec 17, 2024
1 parent 01a7a87 commit 5842868
Show file tree
Hide file tree
Showing 241 changed files with 6,282 additions and 5,842 deletions.
122 changes: 75 additions & 47 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ dependencies {
}

tasks.withType(OpenApi3Task::class.java) {
val multipartformdataPaths = listOf(
"/api/v1/admin/utilities/conversion/image",
"/api/v1/admin/utilities/conversion/content"
)
val multipartformdataPaths =
listOf(
"/api/v1/admin/utilities/conversion/image",
"/api/v1/admin/utilities/conversion/content",
)
doLast {
val input: InputStream = FileInputStream(File("$projectDir/src/main/resources/static/openapi3.yaml"))
val options = DumperOptions().apply {
defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
isPrettyFlow = true
}
val options =
DumperOptions().apply {
defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
isPrettyFlow = true
}
val yaml = Yaml(options)
val yamlData = yaml.loadAll(input)
for (data in yamlData) {
Expand All @@ -83,53 +85,63 @@ tasks.withType(OpenApi3Task::class.java) {
if (methods.containsKey("post")) {
val post = methods["post"] as MutableMap<String, Any>
if (!post.containsKey("requestBody")) {
post["requestBody"] = mutableMapOf(
"content" to mutableMapOf(
"multipart/form-data" to mutableMapOf(
"schema" to mutableMapOf(
"type" to "object",
"properties" to mutableMapOf(
"source" to mutableMapOf(
"type" to "string",
"format" to "binary"
)
)
)
)
post["requestBody"] =
mutableMapOf(
"content" to
mutableMapOf(
"multipart/form-data" to
mutableMapOf(
"schema" to
mutableMapOf(
"type" to "object",
"properties" to
mutableMapOf(
"source" to
mutableMapOf(
"type" to "string",
"format" to "binary",
),
),
),
),
),
)
)
}
}
}
}
val components = content["components"] as MutableMap<String, MutableMap<String, Any>>
components["securitySchemes"] = mutableMapOf(
"bearerAuth" to mutableMapOf(
"type" to "http",
"scheme" to "bearer",
"bearerFormat" to "JWT"
components["securitySchemes"] =
mutableMapOf(
"bearerAuth" to
mutableMapOf(
"type" to "http",
"scheme" to "bearer",
"bearerFormat" to "JWT",
),
)
)
val output = File("$projectDir/src/main/resources/static/openapi3.yaml")
yaml.dump(content, FileWriter(output))
}
}
}

val imageName = project.hasProperty("imageName").let {
if (it) {
project.property("imageName") as String
} else {
"fewletter/api"
val imageName =
project.hasProperty("imageName").let {
if (it) {
project.property("imageName") as String
} else {
"fewletter/api"
}
}
}
val releaseVersion = project.hasProperty("releaseVersion").let {
if (it) {
project.property("releaseVersion") as String
} else {
Random().nextInt(90000) + 10000
val releaseVersion =
project.hasProperty("releaseVersion").let {
if (it) {
project.property("releaseVersion") as String
} else {
Random().nextInt(90000) + 10000
}
}
}

tasks.register("buildDockerImage") {
dependsOn("bootJar")
Expand All @@ -148,16 +160,32 @@ tasks.register("buildDockerImage") {
exec {
workingDir(".")
commandLine(
"docker", "buildx", "build", "--platform=linux/amd64,linux/arm64", "-t",
"$imageName:latest", "--build-arg", "RELEASE_VERSION=$releaseVersion", ".", "--push"
"docker",
"buildx",
"build",
"--platform=linux/amd64,linux/arm64",
"-t",
"$imageName:latest",
"--build-arg",
"RELEASE_VERSION=$releaseVersion",
".",
"--push",
)
}

exec {
workingDir(".")
commandLine(
"docker", "buildx", "build", "--platform=linux/amd64,linux/arm64", "-t",
"$imageName:$releaseVersion", "--build-arg", "RELEASE_VERSION=$releaseVersion", ".", "--push"
"docker",
"buildx",
"build",
"--platform=linux/amd64,linux/arm64",
"-t",
"$imageName:$releaseVersion",
"--build-arg",
"RELEASE_VERSION=$releaseVersion",
".",
"--push",
)
}
}
Expand All @@ -176,7 +204,7 @@ tasks.register("buildEcsDockerImage") {
imageName,
"--build-arg",
"RELEASE_VERSION=$releaseVersion",
'.'
'.',
)
}
}
Expand All @@ -197,7 +225,7 @@ tasks.register("buildPinpointEcsDockerImageDev") {
"RELEASE_VERSION=$releaseVersion",
"-f",
"Dockerfile.dev.pinpoint",
'.'
'.',
)
}
}
Expand All @@ -218,7 +246,7 @@ tasks.register("buildPinpointEcsDockerImagePrd") {
"RELEASE_VERSION=$releaseVersion",
"-f",
"Dockerfile.prd.pinpoint",
'.'
'.',
)
}
}
Expand Down
8 changes: 4 additions & 4 deletions api/src/main/kotlin/com/few/api/config/ApiConfig.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.few.api.config

import email.config.MailConfig
import repo.config.RepoConfig
import storage.document.config.DocumentStorageConfig
import storage.image.config.ImageStorageConfig
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import repo.config.RepoConfig
import security.config.SecurityConfig
import storage.document.config.DocumentStorageConfig
import storage.image.config.ImageStorageConfig
import web.config.WebConfig

@Configuration
Expand All @@ -19,7 +19,7 @@ import web.config.WebConfig
ImageStorageConfig::class,
DocumentStorageConfig::class,
WebConfig::class,
SecurityConfig::class
SecurityConfig::class,
)
@ConfigurationPropertiesScan(basePackages = [ApiConfig.BASE_PACKAGE])
class ApiConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ class ApiDatabaseAccessThreadPoolConfig {

@Bean
@ConfigurationProperties(prefix = "thread-pool.database")
fun databaseAccessThreadPoolProperties(): ApiThreadPoolProperties {
return ApiThreadPoolProperties()
}
fun databaseAccessThreadPoolProperties(): ApiThreadPoolProperties = ApiThreadPoolProperties()

@Bean(DATABASE_ACCESS_POOL)
fun databaseAccessThreadPool() = ThreadPoolTaskExecutor().apply {
val properties = databaseAccessThreadPoolProperties()
corePoolSize = properties.getCorePoolSize()
maxPoolSize = properties.getMaxPoolSize()
queueCapacity = properties.getQueueCapacity()
setWaitForTasksToCompleteOnShutdown(properties.getWaitForTasksToCompleteOnShutdown())
setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds())
setThreadNamePrefix("databaseAccessThreadPool-")
setRejectedExecutionHandler { r, _ ->
log.warn { "Database Access Task Rejected: $r" }
fun databaseAccessThreadPool() =
ThreadPoolTaskExecutor().apply {
val properties = databaseAccessThreadPoolProperties()
corePoolSize = properties.getCorePoolSize()
maxPoolSize = properties.getMaxPoolSize()
queueCapacity = properties.getQueueCapacity()
setWaitForTasksToCompleteOnShutdown(properties.getWaitForTasksToCompleteOnShutdown())
setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds())
setThreadNamePrefix("databaseAccessThreadPool-")
setRejectedExecutionHandler { r, _ ->
log.warn { "Database Access Task Rejected: $r" }
}
initialize()
}
initialize()
}
}
57 changes: 31 additions & 26 deletions api/src/main/kotlin/com/few/api/config/ApiLocalCacheConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.few.api.config

import com.few.api.domain.common.repo.event.ApiLocalCacheEventListener
import io.github.oshai.kotlinlogging.KotlinLogging
import org.ehcache.config.builders.CacheConfigurationBuilder
import org.ehcache.config.builders.ResourcePoolsBuilder
Expand All @@ -13,7 +14,6 @@ import org.springframework.cache.annotation.EnableCaching
import org.springframework.cache.jcache.JCacheCacheManager
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import com.few.api.domain.common.repo.event.ApiLocalCacheEventListener

@Configuration
@EnableCaching
Expand All @@ -29,34 +29,39 @@ class ApiLocalCacheConfig {

@Bean(LOCAL_CM)
fun localCacheManager(): CacheManager {
val cacheEventListenerConfigurationConfig = DefaultCacheEventListenerConfiguration(
setOf(
EventType.CREATED,
EventType.EXPIRED,
EventType.REMOVED,
EventType.UPDATED
),
ApiLocalCacheEventListener::class.java
)
val cacheEventListenerConfigurationConfig =
DefaultCacheEventListenerConfiguration(
setOf(
EventType.CREATED,
EventType.EXPIRED,
EventType.REMOVED,
EventType.UPDATED,
),
ApiLocalCacheEventListener::class.java,
)
val cacheManager = EhcacheCachingProvider().cacheManager

val cache10Configuration = CacheConfigurationBuilder.newCacheConfigurationBuilder(
Any::class.java,
Any::class.java,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(10, EntryUnit.ENTRIES)
)
.withService(cacheEventListenerConfigurationConfig)
.build()
val cache10Configuration =
CacheConfigurationBuilder
.newCacheConfigurationBuilder(
Any::class.java,
Any::class.java,
ResourcePoolsBuilder
.newResourcePoolsBuilder()
.heap(10, EntryUnit.ENTRIES),
).withService(cacheEventListenerConfigurationConfig)
.build()

val cache5Configuration = CacheConfigurationBuilder.newCacheConfigurationBuilder(
Any::class.java,
Any::class.java,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(5, EntryUnit.ENTRIES)
)
.withService(cacheEventListenerConfigurationConfig)
.build()
val cache5Configuration =
CacheConfigurationBuilder
.newCacheConfigurationBuilder(
Any::class.java,
Any::class.java,
ResourcePoolsBuilder
.newResourcePoolsBuilder()
.heap(5, EntryUnit.ENTRIES),
).withService(cacheEventListenerConfigurationConfig)
.build()

val selectArticleRecordCacheConfig: javax.cache.configuration.Configuration<Any, Any> =
Eh107Configuration.fromEhcacheCacheConfiguration(cache10Configuration)
Expand Down
27 changes: 15 additions & 12 deletions api/src/main/kotlin/com/few/api/config/ApiMessageSourceAccessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ import java.util.*
@Component
class ApiMessageSourceAccessor : MessageSourceAware {
override fun setMessageSource(messageSource: MessageSource) {
messageSourceAccessor = MessageSourceAccessor(
messageSource,
Locale.getDefault()
)
messageSourceAccessor =
MessageSourceAccessor(
messageSource,
Locale.getDefault(),
)
}

companion object {
private var messageSourceAccessor: MessageSourceAccessor? = null
fun getMessage(code: String?): String {
return messageSourceAccessor!!.getMessage(
code!!

fun getMessage(code: String?): String =
messageSourceAccessor!!.getMessage(
code!!,
)
}

fun getMessage(code: String?, vararg args: Any?): String {
return messageSourceAccessor!!.getMessage(
fun getMessage(
code: String?,
vararg args: Any?,
): String =
messageSourceAccessor!!.getMessage(
code!!,
args
args,
)
}
}
}
Loading

0 comments on commit 5842868

Please sign in to comment.