Skip to content

Commit

Permalink
Instansier unleash en gang.
Browse files Browse the repository at this point in the history
  • Loading branch information
geiralund committed Apr 29, 2024
1 parent 8a7a429 commit af88ffa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class ApplicationBuilder(env: Map<String, String>) : RapidsConnection.S
private val safClient = SafClient(Config.properties)
private val arenaApiClient = ArenaApiClient(Config.properties)
private val journalpostApiClient = JournalpostApiClient(tokenProvider = Config.properties.dokarkivTokenProvider)
private val gosysOppslag = UnleashGosysClient(Config.properties)
private val gosysOppslag = UnleashGosysClient(Config.properties, unleash)
private val ferdigstiltInnsendingObserver = FerdigstiltInnsendingObserver(Config.kafkaProducerProperties)

private val rapidsConnection =
Expand Down
4 changes: 2 additions & 2 deletions mediator/src/main/kotlin/no/nav/dagpenger/mottak/api/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.ktor.server.auth.jwt.JWTConfigureFunction
import io.ktor.server.auth.jwt.JWTPrincipal
import io.ktor.server.auth.jwt.jwt
import no.nav.dagpenger.mottak.Config
import java.net.URL
import java.net.URI
import java.util.concurrent.TimeUnit

internal fun AuthenticationContext.fnr(): String =
Expand All @@ -36,7 +36,7 @@ internal fun AuthenticationConfig.jwt(
}

private fun cachedJwkProvider(jwksUri: String): JwkProvider {
return JwkProviderBuilder(URL(jwksUri))
return JwkProviderBuilder(URI(jwksUri).toURL())
.cached(10, 24, TimeUnit.HOURS) // cache up to 10 JWKs for 24 hours
.rateLimited(
10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.dagpenger.mottak.behov.saksbehandling.gosys

import com.natpryce.konfig.Configuration
import io.getunleash.Unleash
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.DefaultRequest
Expand All @@ -19,7 +20,6 @@ import no.nav.dagpenger.mottak.Config.dpProxyTokenProvider
import no.nav.dagpenger.mottak.Config.dpProxyUrl
import no.nav.dagpenger.mottak.Config.gosysUrl
import no.nav.dagpenger.mottak.behov.JsonMapper
import no.nav.dagpenger.mottak.unleash
import java.time.LocalDate
import kotlin.time.Duration.Companion.minutes

Expand All @@ -43,7 +43,7 @@ internal data class GosysOppgaveRequest(

internal data class GosysOppgaveResponse(val id: String)

internal class UnleashGosysClient(config: Configuration) : GosysOppslag {
internal class UnleashGosysClient(config: Configuration, private val unleash: Unleash) : GosysOppslag {
private val gosysClient = GosysClient(config)
private val proxyClient = GosysProxyClient(config)

Expand Down

0 comments on commit af88ffa

Please sign in to comment.