Skip to content

Commit

Permalink
IS-2720: Ktor 3.0 (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
geir-waagboe authored Jan 2, 2025
1 parent 1c20eed commit c775e4f
Show file tree
Hide file tree
Showing 28 changed files with 4,722 additions and 4,959 deletions.
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "no.nav.syfo"
version = "1.0-SNAPSHOT"

val confluent = "7.7.1"
val confluent = "7.7.2"
val flyway = "10.17.3"
val hikari = "5.1.0"
val isdialogmoteSchema = "1.0.5"
val jacksonDataType = "2.18.0"
val jedis = "5.2.0"
val json = "20240303"
val kafka = "3.7.0"
val kafka = "3.9.0"
val kluent = "1.73"
val ktor = "2.3.12"
val logback = "1.5.11"
val ktor = "3.0.2"
val logback = "1.5.13"
val logstashEncoder = "7.4"
val mockk = "1.13.13"
val micrometerRegistry = "1.12.8"
val nimbusjosejwt = "9.41.2"
val nimbusjosejwt = "9.47"
val postgresEmbedded = "2.0.7"
val postgres = "42.7.4"
val spek = "2.0.19"

plugins {
kotlin("jvm") version "2.0.21"
id("com.gradleup.shadow") version "8.3.3"
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
id("com.github.davidmc24.gradle.plugin.avro") version "1.8.0"
}

Expand Down
74 changes: 36 additions & 38 deletions src/main/kotlin/no/nav/syfo/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,23 @@ fun main() {
lateinit var personoversiktStatusService: PersonoversiktStatusService
lateinit var oppfolgingstilfelleService: OppfolgingstilfelleService

val applicationEngineEnvironment = applicationEngineEnvironment {
val applicationEnvironment = applicationEnvironment {
log = logger
config = HoconApplicationConfig(ConfigFactory.load())
}

connector {
port = applicationPort
}

module {
val server = embeddedServer(
Netty,
environment = applicationEnvironment,
configure = {
connector {
port = applicationPort
}
connectionGroupSize = 8
workerGroupSize = 8
callGroupSize = 16
},
module = {
databaseModule(
databaseEnvironment = environment.database,
)
Expand Down Expand Up @@ -144,39 +152,29 @@ fun main() {
personBehandlendeEnhetService = personBehandlendeEnhetService,
personoversiktStatusRepository = personoversiktStatusRepository,
)
monitor.subscribe(ApplicationStarted) {
applicationState.ready = true
logger.info("Application is ready, running Java VM ${Runtime.version()}")
launchKafkaModule(
applicationState = applicationState,
environment = environment,
azureAdClient = azureAdClient,
personoversiktStatusService = personoversiktStatusService,
personBehandlendeEnhetService = personBehandlendeEnhetService,
oppfolgingstilfelleService = oppfolgingstilfelleService,
)
launchCronjobModule(
applicationState = applicationState,
database = database,
environment = environment,
redisStore = redisStore,
azureAdClient = azureAdClient,
personBehandlendeEnhetService = personBehandlendeEnhetService,
personoversiktStatusService = personoversiktStatusService,
)
}
}
}

val server = embeddedServer(
environment = applicationEngineEnvironment,
factory = Netty,
) {
connectionGroupSize = 8
workerGroupSize = 8
callGroupSize = 16
}

applicationEngineEnvironment.monitor.subscribe(ApplicationStarted) {
applicationState.ready = true
logger.info("Application is ready, running Java VM ${Runtime.version()}")
launchKafkaModule(
applicationState = applicationState,
environment = environment,
azureAdClient = azureAdClient,
personoversiktStatusService = personoversiktStatusService,
personBehandlendeEnhetService = personBehandlendeEnhetService,
oppfolgingstilfelleService = oppfolgingstilfelleService,
)
launchCronjobModule(
applicationState = applicationState,
database = database,
environment = environment,
redisStore = redisStore,
azureAdClient = azureAdClient,
personBehandlendeEnhetService = personBehandlendeEnhetService,
personoversiktStatusService = personoversiktStatusService,
)
}
)

Runtime.getRuntime().addShutdownHook(
Thread {
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/no/nav/syfo/util/RequestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package no.nav.syfo.util

import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.util.pipeline.*
import io.ktor.server.routing.*
import net.logstash.logback.argument.StructuredArguments
import no.nav.syfo.personstatus.domain.PersonIdent
import java.util.*

const val NAV_PERSONIDENT_HEADER = "nav-personident"

const val NAV_CALL_ID_HEADER = "Nav-Call-Id"
fun PipelineContext<out Unit, ApplicationCall>.getCallId(): String {

fun RoutingContext.getCallId(): String {
return this.call.getCallId()
}

Expand All @@ -31,6 +32,6 @@ fun ApplicationCall.getConsumerId(): String {
return this.request.headers[NAV_CONSUMER_ID_HEADER].toString()
}

fun PipelineContext<out Unit, ApplicationCall>.getBearerHeader(): String? {
fun RoutingContext.getBearerHeader(): String? {
return this.call.request.headers[HttpHeaders.Authorization]?.removePrefix("Bearer ")
}
Loading

0 comments on commit c775e4f

Please sign in to comment.