Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Bruk unleash-next
Browse files Browse the repository at this point in the history
  • Loading branch information
jstnhlj committed Dec 1, 2023
1 parent 120e1ad commit 0356fdf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ NAIS_DATABASE_PAW_ARBEIDSSOKER_PROFILERING_PROFILERING_USERNAME=admin
NAIS_DATABASE_PAW_ARBEIDSSOKER_PROFILERING_PROFILERING_PASSWORD=admin
AAREG_URL=http://localhost:8090/aareg
AAREG_SCOPE=api://dev-gcp.paw.paw-arbeidssoker-profilering/.default
UNLEASH_URL=https://unleash.nais.io/api/
UNLEASH_SERVER_API_URL=https://paw-unleash-api.nav.cloud.nais.io/api
TOKEN_X_WELL_KNOWN_URL=http://localhost:8081/default/.well-known/openid-configuration
TOKEN_X_CLIENT_ID=paw-arbeidssoker-profilering
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ val dotenv_kotlin_version: String by project
val nocommons_version: String by project
val mock_oauth2_server_version: String by project
val avro_version: String by project
val unleash_version: String by project

plugins {
kotlin("jvm") version "1.8.10"
Expand Down Expand Up @@ -98,7 +99,8 @@ dependencies {
// NAV common
implementation("no.nav.common:token-client:$nav_common_modules_version")
implementation("no.nav.common:kafka:$nav_common_modules_version")
implementation("no.nav.common:feature-toggle:$nav_common_modules_version")

implementation("io.getunleash:unleash-client-java:$unleash_version")

// NAV security
implementation("no.nav.security:token-validation-ktor-v2:$token_support_version")
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dotenv_kotlin_version=6.4.1
nocommons_version=0.15.0
mock_oauth2_server_version=0.5.8
avro_version=1.11.0
unleash_version=9.1.1

kotlin.code.style=official
kotlin.incremental=true
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/paw/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import io.ktor.server.application.Application
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.server.routing.routing
import javax.sql.DataSource
import kotlin.concurrent.thread
import no.nav.paw.config.Config
import no.nav.paw.config.migrateDatabase
import no.nav.paw.kafka.consumers.ArbeidssokerRegistreringConsumer
Expand All @@ -16,8 +18,6 @@ import no.nav.paw.routes.apiRoutes
import no.nav.paw.routes.internalRoutes
import no.nav.paw.routes.swaggerRoutes
import org.koin.ktor.ext.inject
import javax.sql.DataSource
import kotlin.concurrent.thread

fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
Expand Down
11 changes: 7 additions & 4 deletions src/main/kotlin/no/nav/paw/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package no.nav.paw.config

import io.github.cdimascio.dotenv.dotenv
import no.nav.security.token.support.v2.RequiredClaims
import io.getunleash.util.UnleashConfig

val dotenv = dotenv { ignoreIfMissing = true }

Expand All @@ -14,10 +15,12 @@ data class Config(
dotenv["NAIS_DATABASE_PAW_ARBEIDSSOKER_PROFILERING_PROFILERING_PASSWORD"]
),
val naisEnv: NaisEnv = NaisEnv.current(),
val unleashClientConfig: UnleashClientConfig = UnleashClientConfig(
dotenv["UNLEASH_URL"],
dotenv["NAIS_APP_NAME"]
),
val unleashClientConfig: UnleashConfig = UnleashConfig.builder()
.appName(dotenv["NAIS_APP_NAME"])
.instanceId(dotenv["NAIS_APP_NAME"])
.unleashAPI(dotenv["UNLEASH_SERVER_API_URL"])
.apiKey(dotenv["UNLEASH_SERVER_API_TOKEN"])
.build(),
val authentication: List<AuthProvider> = listOf(
AuthProvider(
name = "tokenx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package no.nav.paw.kafka.consumers

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.paw.domain.ArbeidssokerRegistrert
import no.nav.paw.services.ProfileringService
import no.nav.paw.utils.CallId.leggTilCallId
Expand All @@ -14,7 +14,7 @@ class ArbeidssokerRegistreringConsumer(
private val topic: String,
private val consumer: KafkaConsumer<String, String>,
private val profileringService: ProfileringService,
private val unleashClient: UnleashClient,
private val unleashClient: Unleash,
private val objectMapper: ObjectMapper
) {

Expand Down
12 changes: 4 additions & 8 deletions src/main/kotlin/no/nav/paw/plugins/DependencyInjection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig
import io.confluent.kafka.serializers.KafkaAvroSerializer
import io.confluent.kafka.serializers.KafkaAvroSerializerConfig
import io.getunleash.Unleash
import io.ktor.client.HttpClient
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.jackson.jackson
import io.ktor.server.application.Application
import io.ktor.server.application.install
import no.nav.common.featuretoggle.ByClusterStrategy
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.featuretoggle.UnleashClientImpl
import no.nav.common.kafka.producer.util.KafkaProducerClientBuilder
import no.nav.common.kafka.util.KafkaPropertiesBuilder
import no.nav.common.kafka.util.KafkaPropertiesPreset
Expand Down Expand Up @@ -59,11 +57,9 @@ fun Application.configureDependencyInjection(config: Config) {
}
}

single<UnleashClient> {
UnleashClientImpl(
config.unleashClientConfig.url,
config.unleashClientConfig.appName,
listOf(ByClusterStrategy())
single<Unleash> {
UnleashDefault(
config.unleashClientConfig
)
}

Expand Down

0 comments on commit 0356fdf

Please sign in to comment.