Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
20 changes: 20 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ dependencyManagement {
group = "io.github.reactivecircus.kstreamlined.backend"
version = "0.0.1-SNAPSHOT"

graalvmNative {
metadataRepository {
enabled.set(true)
}
binaries.configureEach {
resources.autodetect()
}
binaries.named("main") {
buildArgs(
"--strict-image-heap",
"-march=native",
"-R:MaxHeapSize=10m",
)
javaLauncher = javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(21))
vendor.set(JvmVendorSpec.GRAAL_VM)
}
}
}

tasks.withType<GenerateJavaTask>().configureEach {
packageName = "io.github.reactivecircus.kstreamlined.backend.schema.generated"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
package io.github.reactivecircus.kstreamlined.backend

import com.netflix.graphql.dgs.webflux.autoconfiguration.DgsWebfluxConfigurationProperties
import io.github.reactivecircus.kstreamlined.backend.client.ClientConfigs
import io.github.reactivecircus.kstreamlined.backend.client.FeedClient
import io.github.reactivecircus.kstreamlined.backend.client.RealFeedClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.engine.cio.*
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.ImportRuntimeHints

@Configuration
@ImportRuntimeHints(KStreamlinedRuntimeHints::class)
@RegisterReflectionForBinding(
DgsWebfluxConfigurationProperties::class,
DgsWebfluxConfigurationProperties.DgsWebsocketConfigurationProperties::class,
DgsWebfluxConfigurationProperties.DgsGraphiQLConfigurationProperties::class,
DgsWebfluxConfigurationProperties.DgsSchemaJsonConfigurationProperties::class,
)
class KSConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.reactivecircus.kstreamlined.backend

import org.springframework.aot.hint.ExecutableMode
import org.springframework.aot.hint.RuntimeHints
import org.springframework.aot.hint.RuntimeHintsRegistrar
import org.springframework.aot.hint.TypeReference

object KStreamlinedRuntimeHints : RuntimeHintsRegistrar {
override fun registerHints(hints: RuntimeHints, classLoader: ClassLoader?) {
hints.reflection()
.registerType(
TypeReference.of("com.github.benmanes.caffeine.cache.SSA")
) { builder ->
builder.withConstructor(
listOf(
TypeReference.of("com.github.benmanes.caffeine.cache.Caffeine"),
TypeReference.of("com.github.benmanes.caffeine.cache.AsyncCacheLoader"),
TypeReference.of("boolean"),
),
ExecutableMode.INVOKE,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import java.time.Duration
@DgsComponent
class FeedEntryDataFetcher(
private val feedClient: FeedClient,
private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO,
) {
private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO

private val kotlinBlogCacheContext = object : CacheContext<KotlinBlogItem> {
override val cache: Cache<Unit, List<KotlinBlogItem>> = Caffeine
.newBuilder()
Expand Down

0 comments on commit fa152a4

Please sign in to comment.