Skip to content

Commit

Permalink
커넥션 옵션 직접 설정하지 않음 (#312)
Browse files Browse the repository at this point in the history
Co-authored-by: Hank-Choi <[email protected]>
  • Loading branch information
Hank-Choi and Hank-Choi authored Jan 7, 2025
1 parent ee70cbf commit eb7cfca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream

Expand All @@ -12,6 +13,7 @@ plugins {
group = "com.wafflestudio"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

allprojects {
repositories {
Expand Down Expand Up @@ -64,9 +66,9 @@ subprojects {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
jvmTarget.set(JvmTarget.JVM_17)
}
}

Expand Down
21 changes: 4 additions & 17 deletions core/src/main/kotlin/config/ApiWebClientConfig.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.wafflestudio.snu4t.config

import io.netty.channel.ChannelOption
import io.netty.handler.timeout.ReadTimeoutHandler
import io.netty.handler.timeout.WriteTimeoutHandler
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
Expand All @@ -11,9 +8,8 @@ import org.springframework.context.annotation.Profile
import org.springframework.http.client.reactive.ReactorClientHttpConnector
import org.springframework.stereotype.Component
import org.springframework.web.reactive.function.client.WebClient
import reactor.netty.Connection
import reactor.netty.http.client.HttpClient
import java.util.concurrent.TimeUnit
import java.time.Duration

@Configuration
@EnableConfigurationProperties(ApiConfigs::class)
Expand All @@ -27,16 +23,8 @@ class ApiWebClientConfig(
}

private fun create(apiConfig: ApiConfig): WebClient {
val connector =
ReactorClientHttpConnector(
HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, apiConfig.connectTimeout) // Connection Timeout
.doOnConnected { conn: Connection ->
conn
.addHandlerLast(ReadTimeoutHandler(apiConfig.readTimeout, TimeUnit.MILLISECONDS))
.addHandlerLast(WriteTimeoutHandler(apiConfig.readTimeout, TimeUnit.MILLISECONDS))
},
)
val httpClient = HttpClient.create().responseTimeout(Duration.ofMillis(apiConfig.responseTimeout))
val connector = ReactorClientHttpConnector(httpClient)
return WebClient.builder().clientConnector(connector).baseUrl(apiConfig.baseUrl).build()
}
}
Expand All @@ -48,8 +36,7 @@ class ApiConfigs {
}

class ApiConfig {
var connectTimeout: Int = 800
var readTimeout: Long = 1000
var responseTimeout: Long = 2000
lateinit var baseUrl: String
}

Expand Down

0 comments on commit eb7cfca

Please sign in to comment.