diff --git a/apps/kafka-key-generator/build.gradle.kts b/apps/kafka-key-generator/build.gradle.kts index 71b9a1ef..c28da54f 100644 --- a/apps/kafka-key-generator/build.gradle.kts +++ b/apps/kafka-key-generator/build.gradle.kts @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") @@ -13,9 +12,9 @@ val jvmMajorVersion: String by project dependencies { // PAW implementation(project(":lib:hoplite-config")) - implementation(project(":lib:error-handling")) - implementation(project(":lib:http-client-utils")) - implementation(project(":lib:pdl-client")) + implementation(project(":lib:error-handling-ktor3")) + implementation(project(":lib:http-client-utils-ktorv3")) + implementation(project(":lib:pdl-client-ktor3")) implementation(project(":lib:kafka")) implementation(project(":domain:interne-hendelser")) @@ -23,27 +22,27 @@ dependencies { implementation(libs.nav.common.log) implementation(libs.nav.common.tokenClient) implementation(libs.nav.security.tokenClientCore) - implementation(libs.nav.security.tokenValidationKtorV2) + implementation(libs.nav.security.tokenValidationKtorV3) // Kafka (for å beregne partisjonsnummer) implementation(libs.kafka.clients) // Ktor - implementation(libs.ktor.serialization.jackson) + implementation(libs.ktor3.serialization.jackson) // Ktor Server - implementation(libs.bundles.ktorServerWithNettyAndMicrometer) - implementation(libs.ktor.server.cors) - implementation(libs.ktor.server.swagger) - implementation(libs.ktor.server.callId) - implementation(libs.ktor.server.statusPages) - implementation(libs.ktor.server.contentNegotiation) + implementation(libs.bundles.ktor3ServerWithNettyAndMicrometer) + implementation(libs.ktor3.server.cors) + implementation(libs.ktor3.server.swagger) + implementation(libs.ktor3.server.callId) + implementation(libs.ktor3.server.statusPages) + implementation(libs.ktor3.server.contentNegotiation) // Ktor Client - implementation(libs.ktor.client.contentNegotiation) - implementation(libs.ktor.client.core) - implementation(libs.ktor.client.cio) - implementation(libs.ktor.client.logging) + implementation(libs.ktor3.client.contentNegotiation) + implementation(libs.ktor3.client.core) + implementation(libs.ktor3.client.cio) + implementation(libs.ktor3.client.logging) // Micrometer & OTEL implementation(libs.micrometer.registryPrometheus) @@ -73,8 +72,8 @@ dependencies { testImplementation(libs.bundles.testLibsWithUnitTesting) testImplementation(libs.test.testContainers.core) testImplementation(libs.test.testContainers.postgresql) - testImplementation(libs.ktor.server.testJvm) - testImplementation(libs.ktor.client.mock) + testImplementation(libs.ktor3.server.test.host) + testImplementation(libs.ktor3.client.mock) } java { diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/Application.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/Application.kt index a2797694..a968a147 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/Application.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/Application.kt @@ -1,5 +1,6 @@ package no.nav.paw.kafkakeygenerator +import io.ktor.server.engine.EngineConnectorBuilder import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics @@ -94,12 +95,14 @@ fun startApplication( ) embeddedServer( - factory = Netty, - port = 8080, + Netty, configure = { connectionGroupSize = 8 workerGroupSize = 8 callGroupSize = 16 + connectors.add(EngineConnectorBuilder().apply { + port = 8080 + }) } ) { configSerialization() diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/recordkey/RecordKeyApi.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/recordkey/RecordKeyApi.kt index 0f813a2d..ecb9d3b8 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/recordkey/RecordKeyApi.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/recordkey/RecordKeyApi.kt @@ -1,11 +1,9 @@ package no.nav.paw.kafkakeygenerator.api.recordkey -import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import io.opentelemetry.instrumentation.annotations.WithSpan import no.nav.paw.kafkakeygenerator.api.recordkey.functions.recordKey import no.nav.paw.kafkakeygenerator.config.AuthenticationConfig @@ -29,7 +27,7 @@ fun Routing.configureRecordKeyApi( } @WithSpan -private suspend fun PipelineContext.handleRequest( +private suspend fun RoutingContext.handleRequest( kafkaKeysService: KafkaKeysService, logger: Logger ) { diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/v2/ApiEndepunktV2.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/v2/ApiEndepunktV2.kt index 28c99d79..609c37db 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/v2/ApiEndepunktV2.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/api/v2/ApiEndepunktV2.kt @@ -3,12 +3,10 @@ package no.nav.paw.kafkakeygenerator.api.v2 import io.ktor.http.* import io.ktor.http.HttpStatusCode.Companion.InternalServerError import io.ktor.http.HttpStatusCode.Companion.OK -import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import io.opentelemetry.instrumentation.annotations.WithSpan import no.nav.paw.kafkakeygenerator.service.KafkaKeysService import no.nav.paw.kafkakeygenerator.vo.FailureCode @@ -40,7 +38,7 @@ fun Routing.konfigurerApiV2( } @WithSpan -suspend fun PipelineContext.hentLokalInfo( +suspend fun RoutingContext.hentLokalInfo( kafkaKeysService: KafkaKeysService, logger: Logger ) { @@ -62,7 +60,7 @@ suspend fun PipelineContext.hentLokalInfo( } @WithSpan -suspend fun PipelineContext.hentInfo( +suspend fun RoutingContext.hentInfo( kafkaKeysService: KafkaKeysService, logger: Logger ) { @@ -80,7 +78,7 @@ suspend fun PipelineContext.hentInfo( } @WithSpan -private suspend fun PipelineContext.hentEllerOpprett( +private suspend fun RoutingContext.hentEllerOpprett( kafkaKeysService: KafkaKeysService, logger: Logger ) { diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Authentication.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Authentication.kt index a31920cd..81262411 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Authentication.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Authentication.kt @@ -3,10 +3,10 @@ package no.nav.paw.kafkakeygenerator.plugin import io.ktor.server.application.Application import io.ktor.server.auth.authentication import no.nav.paw.kafkakeygenerator.config.AuthenticationConfig -import no.nav.security.token.support.v2.IssuerConfig -import no.nav.security.token.support.v2.RequiredClaims -import no.nav.security.token.support.v2.TokenSupportConfig -import no.nav.security.token.support.v2.tokenValidationSupport +import no.nav.security.token.support.v3.IssuerConfig +import no.nav.security.token.support.v3.RequiredClaims +import no.nav.security.token.support.v3.TokenSupportConfig +import no.nav.security.token.support.v3.tokenValidationSupport fun Application.configureAuthentication(authenticationConfig: AuthenticationConfig) { authentication { diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Logging.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Logging.kt index e915b3dd..cad5ee7f 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Logging.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/Logging.kt @@ -3,7 +3,7 @@ package no.nav.paw.kafkakeygenerator.plugin import io.ktor.http.HttpStatusCode import io.ktor.server.application.Application import io.ktor.server.application.install -import io.ktor.server.plugins.callloging.CallLogging +import io.ktor.server.plugins.calllogging.CallLogging import io.ktor.server.request.path fun Application.configureLogging() { diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/FlywayPlugin.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/FlywayPlugin.kt index f11d8e99..648401e5 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/FlywayPlugin.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/FlywayPlugin.kt @@ -7,7 +7,7 @@ import io.ktor.server.application.ApplicationStarted import io.ktor.server.application.createApplicationPlugin import io.ktor.server.application.hooks.MonitoringEvent import io.ktor.server.application.log -import io.ktor.util.KtorDsl +import io.ktor.utils.io.KtorDsl import org.flywaydb.core.Flyway import javax.sql.DataSource @@ -32,7 +32,7 @@ val FlywayPlugin: ApplicationPlugin = on(MonitoringEvent(ApplicationStarted)) { application -> application.log.info("Running database migration") dataSource.flywayMigrate(baselineOnMigrate) - application.environment.monitor.raise(FlywayMigrationCompleted, application) + application.monitor.raise(FlywayMigrationCompleted, application) } } diff --git a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/KafkaConsumerPlugin.kt b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/KafkaConsumerPlugin.kt index 34f90e8a..f955cf6f 100644 --- a/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/KafkaConsumerPlugin.kt +++ b/apps/kafka-key-generator/src/main/kotlin/no/nav/paw/kafkakeygenerator/plugin/custom/KafkaConsumerPlugin.kt @@ -8,7 +8,7 @@ import io.ktor.server.application.ApplicationStopping import io.ktor.server.application.createApplicationPlugin import io.ktor.server.application.hooks.MonitoringEvent import io.ktor.server.application.log -import io.ktor.util.KtorDsl +import io.ktor.utils.io.KtorDsl import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch @@ -69,7 +69,7 @@ fun kafkaConsumerPlugin(): ApplicationPlugin logger.info("Kafka Consumer klargjøres") kafkaConsumer.subscribe(kafkaTopics, rebalanceListener) - application.environment.monitor.raise(KafkaConsumerReady, application) + application.monitor.raise(KafkaConsumerReady, application) } on(MonitoringEvent(ApplicationStopping)) { _ ->