Skip to content

Commit

Permalink
Make webflux as implementation && Use its own objectMapper (#6)
Browse files Browse the repository at this point in the history
* logback integration

* make exception not null for protocol

* use HubAdapter

* fix test

* reflect review

* impl webflux & use own jackson
  • Loading branch information
davin111 authored May 17, 2023
1 parent 5d89558 commit 4c06e05
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {

dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:3.0.1")
mavenBom("org.springframework.boot:spring-boot-dependencies:3.0.3")
}
}

Expand Down
8 changes: 5 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
rootProject.name = "truffle-kotlin"

include("truffle-core")
include("truffle-logback")
include("truffle-spring-boot-starter")
include(
"truffle-core",
"truffle-logback",
"truffle-spring-boot-starter",
)
4 changes: 3 additions & 1 deletion truffle-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dependencies {
compileOnly("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework:spring-webflux")
implementation("org.slf4j:slf4j-api")
compileOnly("ch.qos.logback:logback-classic")
}
5 changes: 5 additions & 0 deletions truffle-core/src/main/kotlin/TruffleClient.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.truffle.sdk.core

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.wafflestudio.truffle.sdk.core.protocol.TruffleEvent
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
Expand All @@ -8,6 +9,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.reactor.awaitSingle
import org.slf4j.LoggerFactory
import org.springframework.http.codec.json.Jackson2JsonEncoder
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.bodyToMono
import java.time.Duration
Expand All @@ -29,6 +31,9 @@ internal class DefaultTruffleClient(
Executors.newSingleThreadExecutor { r -> Thread(r, "truffle-client") }.asCoroutineDispatcher()
)
val webClient = webClientBuilder
.codecs {
it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(jacksonObjectMapper()))
}
.baseUrl("https://truffle-api.wafflestudio.com")
.defaultHeader("x-api-key", apiKey)
.build()
Expand Down

This file was deleted.

0 comments on commit 4c06e05

Please sign in to comment.