diff --git a/mediator/src/main/kotlin/no/nav/dagpenger/mottak/Unleash.kt b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/Unleash.kt new file mode 100644 index 00000000..0af94f80 --- /dev/null +++ b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/Unleash.kt @@ -0,0 +1,25 @@ +package no.nav.dagpenger.mottak + +import com.natpryce.konfig.Key +import com.natpryce.konfig.stringType +import io.getunleash.DefaultUnleash +import io.getunleash.Unleash +import io.getunleash.util.UnleashConfig +import no.nav.dagpenger.mottak.Config.properties +import java.net.InetAddress + +val unleash: Unleash by lazy { + DefaultUnleash( + UnleashConfig.builder() + .appName(properties[Key("NAIS_APP_NAME", stringType)]) + .instanceId(runCatching { InetAddress.getLocalHost().hostName }.getOrElse { "ukjent" }) + .unleashAPI(properties[Key("UNLEASH_SERVER_API_URL", stringType)] + "/api/") + .apiKey(properties[Key("UNLEASH_SERVER_API_TOKEN", stringType)]) + .environment( + when (System.getenv("NAIS_CLUSTER_NAME").orEmpty()) { + "prod-gcp" -> "production" + else -> "development" + }, + ).build(), + ) +} diff --git a/mediator/src/main/kotlin/no/nav/dagpenger/mottak/observers/FerdigstiltInnsendingObserver.kt b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/observers/FerdigstiltInnsendingObserver.kt index a9133ddf..b700fd91 100644 --- a/mediator/src/main/kotlin/no/nav/dagpenger/mottak/observers/FerdigstiltInnsendingObserver.kt +++ b/mediator/src/main/kotlin/no/nav/dagpenger/mottak/observers/FerdigstiltInnsendingObserver.kt @@ -2,6 +2,7 @@ package no.nav.dagpenger.mottak.observers import mu.KotlinLogging import no.nav.dagpenger.mottak.InnsendingObserver +import no.nav.dagpenger.mottak.unleash import no.nav.helse.rapids_rivers.JsonMessage import org.apache.kafka.clients.producer.KafkaProducer import org.apache.kafka.clients.producer.Producer @@ -38,6 +39,7 @@ internal class FerdigstiltInnsendingObserver internal constructor(private val pr val payload = event.toPayload().also { it["@event_name"] = "innsending_ferdigstilt" + it["bruk-dp-behandling"] = unleash.isEnabled("bruk-dp-behandling") } publish(