Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Run Lint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Publish release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Publish snapshot
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Run Lint
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
## 와플스튜디오 스프링 라이브러리
- 와플스튜디오에서 사용하는 스프링 라이브러리 모음

## 배포된 라이브러리 위치
- AWS CodeArtifact
- 리포지토리 URL: `https://wafflestudio-405906814034.d.codeartifact.ap-northeast-1.amazonaws.com/maven/spring-waffle/`

## Compatibility
- version 2.0.0 ~
- JDK 21 이상
- spring boot 4.0 이상
- version 1.0.0 ~ 1.0.4
- JDK 17 이상
- spring boot 3.x

## 사용법
### AWS 설정
- AWS 콘솔에 로그인
Expand Down
27 changes: 12 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.Properties

plugins {
id("org.springframework.boot") version "3.2.4" apply false
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.8.0"
kotlin("plugin.spring") version "1.8.0"
id("org.springframework.boot") version "4.0.1" apply false
kotlin("jvm") version "2.2.0"
kotlin("plugin.spring") version "2.2.0"
id("org.jlleitschuh.gradle.ktlint") version "12.2.0"
id("maven-publish")
}

java.sourceCompatibility = JavaVersion.VERSION_17
java.sourceCompatibility = JavaVersion.VERSION_21
java.targetCompatibility = JavaVersion.VERSION_21

allprojects {
repositories {
Expand All @@ -32,13 +33,9 @@ allprojects {
withJavadocJar()
}

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

dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))

implementation(kotlin("stdlib"))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
Expand Down Expand Up @@ -73,9 +70,9 @@ allprojects {
}

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

Expand All @@ -84,7 +81,7 @@ allprojects {
}
}

task("updateVersion") {
tasks.register("updateVersion") {
properties["releaseVersion"]?.let { releaseVersion ->
val newSnapshotVersion =
(releaseVersion as String).split(".").let {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sun May 04 17:42:48 UTC 2025
kotlin.code.style=official
version=1.1.0-SNAPSHOT
version=2.0.0
group=com.wafflestudio.spring
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.wafflestudio.spring.secretsmanager.config

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.springframework.boot.EnvironmentPostProcessor
import org.springframework.boot.SpringApplication
import org.springframework.boot.env.EnvironmentPostProcessor
import org.springframework.core.env.ConfigurableEnvironment
import org.springframework.core.env.MapPropertySource
import software.amazon.awssdk.regions.Region
Expand All @@ -18,6 +18,10 @@ class SecretsManagerEnvironmentPostProcessor : EnvironmentPostProcessor {
environment: ConfigurableEnvironment,
application: SpringApplication,
) {
val isAotProcessing = environment.getProperty("spring.aot.processing", Boolean::class.java, false)
if (isAotProcessing) {
return
}
val secretNamesProperty = environment.getProperty("secret-names") ?: return
val secretNames = secretNamesProperty.split(",")
val secrets = mutableMapOf<String, Any>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.springframework.boot.env.EnvironmentPostProcessor=com.wafflestudio.spring.secretsmanager.config.SecretsManagerEnvironmentPostProcessor
org.springframework.boot.EnvironmentPostProcessor=com.wafflestudio.spring.secretsmanager.config.SecretsManagerEnvironmentPostProcessor
40 changes: 28 additions & 12 deletions truffle/truffle-core/src/main/kotlin/TruffleClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package com.wafflestudio.spring.truffle.core

import com.wafflestudio.spring.truffle.core.protocol.TruffleEvent
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.apache.hc.client5.http.config.ConnectionConfig
import org.apache.hc.client5.http.impl.classic.HttpClients
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager
import org.apache.hc.core5.util.Timeout
import org.slf4j.LoggerFactory
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.web.client.RestClient
import java.time.Duration
import java.util.concurrent.Executors

internal interface TruffleClient {
Expand All @@ -31,30 +33,44 @@ internal class DefaultTruffleClient(
Thread(r, "truffle-client").apply { isDaemon = true }
}.asCoroutineDispatcher(),
)
val clientHttpRequestFactory =
HttpComponentsClientHttpRequestFactory().apply {
setConnectTimeout(Duration.ofSeconds(5))
setConnectionRequestTimeout(Duration.ofSeconds(1))

val connectionManager =
PoolingHttpClientConnectionManager().apply {
maxTotal = 3
defaultMaxPerRoute = 3
setDefaultConnectionConfig(
ConnectionConfig.custom()
.setSocketTimeout(Timeout.ofSeconds(5))
.setConnectTimeout(Timeout.ofSeconds(5))
.build(),
)
}

val httpClient =
HttpClients.custom()
.setConnectionManager(connectionManager)
.build()

val requestFactory = HttpComponentsClientHttpRequestFactory(httpClient)

val restClient =
restClientBuilder
.requestFactory(clientHttpRequestFactory)
.requestFactory(requestFactory)
.baseUrl("https://truffle-api.wafflestudio.com")
.defaultHeader("x-api-key", apiKey)
.build()

coroutineScope.launch(SupervisorJob()) {
events.collect {
coroutineScope.launch {
events.collect { event ->
runCatching {
restClient
.post()
.uri("/events")
.body(it)
.body(event)
.retrieve()
.toBodilessEntity()
}.getOrElse {
logger.warn("Failed to request to truffle server", it)
}.getOrElse { error ->
logger.warn("Failed to request to truffle server", error)
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions truffle/truffle-core/src/main/kotlin/protocol/TruffleAppInfo.kt

This file was deleted.

11 changes: 10 additions & 1 deletion truffle/truffle-core/src/main/kotlin/protocol/TruffleEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ package com.wafflestudio.spring.truffle.core.protocol

data class TruffleEvent(
val version: String = TruffleVersion.V1,
val runtime: TruffleAppInfo.TruffleRuntime = TruffleAppInfo.runtime,
val runtime: TruffleRuntime = truffleRuntime,
val level: TruffleLevel,
val exception: TruffleException,
) {
companion object {
val truffleRuntime: TruffleRuntime = TruffleRuntime()
}
}

data class TruffleRuntime(
val name: String = "Java",
val version: String = System.getProperty("java.version"),
)
22 changes: 11 additions & 11 deletions truffle/truffle-core/src/main/kotlin/protocol/TruffleException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ package com.wafflestudio.spring.truffle.core.protocol
data class TruffleException(
val className: String,
val message: String?,
val elements: List<Element>,
) {
data class Element(
val className: String,
val methodName: String,
val lineNumber: Int,
val fileName: String,
val isInAppInclude: Boolean,
)
}
val elements: List<TruffleExceptionElement>,
)

data class TruffleExceptionElement(
val className: String,
val methodName: String,
val lineNumber: Int,
val fileName: String,
val isInAppInclude: Boolean,
)

fun TruffleException(e: Throwable): TruffleException =
TruffleException(
className = e.javaClass.name,
message = e.message,
elements =
e.stackTrace.map {
TruffleException.Element(
TruffleExceptionElement(
className = it.className,
methodName = it.methodName,
lineNumber = it.lineNumber,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"reflection": [
{
"type": "com.wafflestudio.spring.truffle.core.protocol.TruffleEvent",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"queryAllDeclaredMethods": true,
"queryAllDeclaredConstructors": true
},
{
"type": "com.wafflestudio.spring.truffle.core.protocol.TruffleRuntime",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"queryAllDeclaredMethods": true,
"queryAllDeclaredConstructors": true
},
{
"type": "com.wafflestudio.spring.truffle.core.protocol.TruffleException",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"queryAllDeclaredMethods": true,
"queryAllDeclaredConstructors": true
},
{
"type": "com.wafflestudio.spring.truffle.core.protocol.TruffleExceptionElement",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"queryAllDeclaredMethods": true,
"queryAllDeclaredConstructors": true
},
{
"type": "kotlin.Metadata",
"allDeclaredMethods": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.wafflestudio.spring.truffle.core.IHub
import com.wafflestudio.spring.truffle.core.Truffle
import com.wafflestudio.spring.truffle.core.protocol.TruffleEvent
import com.wafflestudio.spring.truffle.core.protocol.TruffleException
import com.wafflestudio.spring.truffle.core.protocol.TruffleExceptionElement
import com.wafflestudio.spring.truffle.core.protocol.TruffleLevel

class TruffleAppender : UnsynchronizedAppenderBase<ILoggingEvent>() {
Expand Down Expand Up @@ -34,7 +35,7 @@ class TruffleAppender : UnsynchronizedAppenderBase<ILoggingEvent>() {
message = eventObject.formattedMessage,
elements =
eventObject.callerData.map {
TruffleException.Element(
TruffleExceptionElement(
className = it.className,
methodName = it.methodName,
fileName = it.fileName ?: "",
Expand Down