Skip to content

Commit

Permalink
PEK-519 bruk ulike clienter for selve simulering avhengig av miljø
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfofanov committed Aug 28, 2024
1 parent 5b3b670 commit 7cbf702
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.slf4j.MDC
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.http.MediaType
import org.springframework.http.client.reactive.ReactorClientHttpConnector
import org.springframework.web.reactive.function.client.ClientRequest
Expand All @@ -24,11 +25,18 @@ import reactor.netty.http.client.HttpClient
@Configuration
class WebClientConfig {

@Profile(value = ["prod", "preprod"])
@Bean
fun httpClient(): HttpClient =
HttpClient.create().proxyWithSystemProperties().option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS)
.doOnConnected { it.addHandlerLast(ReadTimeoutHandler(READ_TIMEOUT_MILLIS / 1000)) }

@Profile(value = ["prod-gcp", "dev-gcp"])
@Bean
fun client(): HttpClient =
HttpClient.create().option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS)
.doOnConnected { it.addHandlerLast(ReadTimeoutHandler(READ_TIMEOUT_MILLIS / 1000)) }

@Bean
fun webClient(httpClient: HttpClient): WebClient =
WebClient.builder().clientConnector(ReactorClientHttpConnector(httpClient))
Expand Down

0 comments on commit 7cbf702

Please sign in to comment.