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

Commit

Permalink
Oppdater til å bruke io.getunleash/unleash-client-java istedet for na…
Browse files Browse the repository at this point in the history
…v.common/feature-toggle
  • Loading branch information
jstnhlj committed Nov 30, 2023
1 parent 7351c9e commit 4d2e917
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 74 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
<artifactId>job</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>no.nav.common</groupId>
<artifactId>feature-toggle</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>no.nav.common</groupId>
<artifactId>token-client</artifactId>
Expand Down Expand Up @@ -188,6 +183,11 @@
<scope>runtime</scope>
<version>1</version>
</dependency>
<dependency>
<groupId>io.getunleash</groupId>
<artifactId>unleash-client-java</artifactId>
<version>9.1.1</version>
</dependency>


<!-- Test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.DefaultUnleash
import io.getunleash.Unleash
import no.nav.common.log.MDCConstants
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeMapper.Companion.map
Expand All @@ -25,7 +26,7 @@ class FormidlingsgruppeKafkaConsumer internal constructor(
private val kafkaConsumerProperties: Properties,
private val topic: String,
private val formidlingsgruppeMottakService: FormidlingsgruppeMottakService,
private val unleashClient: UnleashClient
private val unleashClient: Unleash
) : Runnable {
init {
val forsinkelseIMinutterVedOppstart = 5
Expand Down Expand Up @@ -96,4 +97,4 @@ class FormidlingsgruppeKafkaConsumer internal constructor(
private const val mdcTopicKey = "topic"
private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvFormidlingsgruppe"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.kafka

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.common.log.MDCConstants
import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService
import no.nav.fo.veilarbregistrering.config.objectMapper
Expand All @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
class MeldekortKafkaConsumer internal constructor(
private val kafkaConsumerProperties: Properties,
private val topic: String,
private val unleashClient: UnleashClient,
private val unleashClient: Unleash,
private val meldekortMottakService: MeldekortMottakService
) : Runnable {
init {
Expand Down Expand Up @@ -93,4 +93,4 @@ class MeldekortKafkaConsumer internal constructor(
private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvMeldekort"
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.fo.veilarbregistrering.config

import io.getunleash.Unleash
import no.nav.common.auth.context.AuthContextHolder
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.health.selftest.SelfTestChecks
Expand Down Expand Up @@ -189,7 +190,7 @@ class ServiceBeansConfig {
fun sykmeldtResource(
tilgangskontrollService: TilgangskontrollService,
userService: UserService,
unleashClient: UnleashClient,
unleashClient: Unleash,
sykmeldtRegistreringService: SykmeldtRegistreringService,
navVeilederService: NavVeilederService,
): SykmeldtResource {
Expand All @@ -201,7 +202,7 @@ class ServiceBeansConfig {
@Bean
fun reaktiveringResource(
userService: UserService,
unleashClient: UnleashClient,
unleashClient: Unleash,
tilgangskontrollService: TilgangskontrollService,
reaktiveringBrukerService: ReaktiveringBrukerService
): ReaktiveringResource {
Expand All @@ -216,7 +217,7 @@ class ServiceBeansConfig {
userService: UserService,
brukerRegistreringService: BrukerRegistreringService,
navVeilederService: NavVeilederService,
unleashClient: UnleashClient
unleashClient: Unleash
): OrdinaerBrukerRegistreringResource {
return OrdinaerBrukerRegistreringResource(
tilgangskontrollService, userService, brukerRegistreringService, navVeilederService, unleashClient
Expand Down Expand Up @@ -259,7 +260,7 @@ class ServiceBeansConfig {
}

@Bean
fun featuretoggleResource(unleashClient: UnleashClient): FeaturetoggleResource {
fun featuretoggleResource(unleashClient: Unleash): FeaturetoggleResource {
return FeaturetoggleResource(unleashClient)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package no.nav.fo.veilarbregistrering.featuretoggle

import no.nav.common.auth.context.AuthContextHolder
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.featuretoggle.UnleashClientImpl
import no.nav.fo.veilarbregistrering.config.requireApplicationName
import io.getunleash.DefaultUnleash
import io.getunleash.Unleash
import io.getunleash.util.UnleashConfig
import no.nav.fo.veilarbregistrering.config.requireProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand All @@ -12,15 +11,23 @@ import org.springframework.context.annotation.Configuration
class UnleashConfig {

@Bean
fun unleashClient(authContextHolder: AuthContextHolder): UnleashClient {
return UnleashClientImpl(
requireProperty(UNLEASH_API_URL_PROPERTY),
requireApplicationName(),
listOf(ByUserIdStrategy(authContextHolder))
)
fun unleashClient(): Unleash {
val unleashApiUrl = requireProperty(UNLEASH_SERVER_API_URL)
val config = UnleashConfig.builder()
.appName(APP_NAME)
.environment(requireProperty(UNLEASH_ENVIRONMENT))
.instanceId(APP_NAME)
.unleashAPI("$unleashApiUrl/api")
.apiKey(requireProperty(UNLEASH_SERVER_API_TOKEN))
.build()

return DefaultUnleash(config)
}

companion object {
const val UNLEASH_API_URL_PROPERTY = "UNLEASH_API_URL"
const val UNLEASH_SERVER_API_URL = "UNLEASH_SERVER_API_URL"
const val UNLEASH_SERVER_API_TOKEN = "UNLEASH_SERVER_API_TOKEN"
const val UNLEASH_ENVIRONMENT = "UNLEASH_ENVIRONMENT"
const val APP_NAME = "veilarbregistrering"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package no.nav.fo.veilarbregistrering.featuretoggle.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
class FeaturetoggleResource(private val unleashClient: UnleashClient) {
class FeaturetoggleResource(private val unleashClient: Unleash) {

@GetMapping("/api/featuretoggle")
fun hentFeatureToggles(@RequestParam("feature") vararg featureName: String): Map<String, Boolean> {
return featureName.associateWith { unleashClient.isEnabled(it) }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.fo.veilarbregistrering.helsesjekk

import no.nav.common.abac.Pep
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.health.selftest.SelfTestCheck
import no.nav.common.health.selftest.SelfTestChecks
import no.nav.common.health.selftest.SelfTestMeterBinder
Expand All @@ -23,7 +22,7 @@ class HelsesjekkConfig {
fun selfTestChecks(
dbHelsesjekk: DatabaseHelsesjekk,
veilarbPep: Pep,
unleashClient: UnleashClient,
// unleashClient: Unleash,
oppfolgingClient: OppfolgingClient,
krrClient: DigDirKrrProxyClient,
aaregRestClient: AaregRestClient,
Expand All @@ -35,7 +34,7 @@ class HelsesjekkConfig {
val selfTestChecks = listOf(
SelfTestCheck("Ping (sporring) mot Databasen til veilarregistrering.", true, dbHelsesjekk),
SelfTestCheck("Ping mot ABAC tilgangskontroll", true, veilarbPep.abacClient),
SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient),
// SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient),
SelfTestCheck("Ping Oppfolging", false, oppfolgingClient),
SelfTestCheck("Ping Kontakt og reservasjonsregisteret (KRR)", false, krrClient),
SelfTestCheck("Ping Arbeid og arbeidstager registeret (Aareg)", false, aaregRestClient),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig
import io.confluent.kafka.serializers.KafkaAvroDeserializerConfig
import io.confluent.kafka.serializers.KafkaAvroSerializer
import io.confluent.kafka.serializers.KafkaAvroSerializerConfig
import io.getunleash.Unleash
import no.nav.arbeid.soker.profilering.ArbeidssokerProfilertEvent
import no.nav.arbeid.soker.registrering.ArbeidssokerRegistrertEvent
import no.nav.common.featuretoggle.UnleashClient
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeKafkaConsumer
import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService
Expand Down Expand Up @@ -82,7 +82,7 @@ class KafkaConfig {

@Bean
fun formidlingsgruppeKafkaConsumer(
unleashClient: UnleashClient,
unleashClient: Unleash,
formidlingsgruppeMottakService: FormidlingsgruppeMottakService
): FormidlingsgruppeKafkaConsumer {
val envSuffix = if (isProduction()) "p" else "q"
Expand All @@ -100,7 +100,7 @@ class KafkaConfig {

@Bean
fun meldekortKafkaConsumer(
unleashClient: UnleashClient,
unleashClient: Unleash,
meldekortMottakService: MeldekortMottakService
): MeldekortKafkaConsumer {
val envSuffix = if (isProduction()) "p" else "q1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.ordinaer.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService
import no.nav.fo.veilarbregistrering.bruker.UserService
import no.nav.fo.veilarbregistrering.registrering.ordinaer.BrukerRegistreringService
Expand All @@ -18,7 +18,7 @@ class OrdinaerBrukerRegistreringResource(
private val userService: UserService,
private val brukerRegistreringService: BrukerRegistreringService,
private val navVeilederService: NavVeilederService,
private val unleashClient: UnleashClient
private val unleashClient: Unleash
) : OrdinaerBrukerRegistreringApi {

@PostMapping("/fullfoerordinaerregistrering")
Expand All @@ -38,4 +38,4 @@ class OrdinaerBrukerRegistreringResource(
}

private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.publisering.scheduler

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.common.job.leader_election.LeaderElectionClient
import no.nav.fo.veilarbregistrering.log.CallId
import no.nav.fo.veilarbregistrering.registrering.publisering.PubliseringAvEventsService
Expand All @@ -11,7 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled
class PubliseringAvRegistreringEventsScheduler(
private val publiseringAvEventsService: PubliseringAvEventsService,
private val leaderElectionClient: LeaderElectionClient,
private val unleashClient: UnleashClient
private val unleashClient: Unleash
) {
@Scheduled(cron = HVERT_TIENDE_SEKUND)
fun publiserRegistreringEvents() {
Expand All @@ -34,4 +34,4 @@ class PubliseringAvRegistreringEventsScheduler(
private val LOG = LoggerFactory.getLogger(PubliseringAvRegistreringEventsScheduler::class.java)
const val HVERT_TIENDE_SEKUND = "0/10 * * * * *"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.publisering.scheduler

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.common.job.leader_election.LeaderElectionClient
import no.nav.common.job.leader_election.LeaderElectionHttpClient
import no.nav.fo.veilarbregistrering.registrering.publisering.PubliseringAvEventsService
Expand All @@ -21,11 +21,11 @@ class PubliseringSchedulerConfig {
fun publiseringAvRegistreringEventsScheduler(
publiseringAvEventsService: PubliseringAvEventsService,
leaderElectionClient: LeaderElectionClient,
unleashClient: UnleashClient
unleashClient: Unleash
): PubliseringAvRegistreringEventsScheduler {
return PubliseringAvRegistreringEventsScheduler(
publiseringAvEventsService,
leaderElectionClient,
unleashClient)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.reaktivering.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.fo.veilarbregistrering.arbeidssoker.perioder.resources.Fnr
import no.nav.fo.veilarbregistrering.autorisasjon.CefMelding
import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService
Expand All @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*
@RequestMapping("/api")
class ReaktiveringResource(
private val userService: UserService,
private val unleashClient: UnleashClient,
private val unleashClient: Unleash,
private val tilgangskontrollService: TilgangskontrollService,
private val reaktiveringBrukerService: ReaktiveringBrukerService
) : ReaktiveringApi {
Expand Down Expand Up @@ -54,4 +54,4 @@ class ReaktiveringResource(
}

private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.sykmeldt.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService
import no.nav.fo.veilarbregistrering.bruker.UserService
import no.nav.fo.veilarbregistrering.registrering.sykmeldt.SykmeldtRegistrering
Expand All @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*
class SykmeldtResource(
private val tilgangskontrollService: TilgangskontrollService,
private val userService: UserService,
private val unleashClient: UnleashClient,
private val unleashClient: Unleash,
private val sykmeldtRegistreringService: SykmeldtRegistreringService,
private val navVeilederService: NavVeilederService
) : SykmeldtApi {
Expand All @@ -32,4 +32,4 @@ class SykmeldtResource(
}

private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid")
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package no.nav.fo.veilarbregistrering.featuretoggle

import io.getunleash.Unleash
import io.mockk.mockk
import no.nav.common.featuretoggle.UnleashClient
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class UnleashConfig {
@Bean
fun unleashClient(): UnleashClient = mockk(relaxed = true)
}
fun unleashClient(): Unleash = mockk(relaxed = true)
}
Loading

0 comments on commit 4d2e917

Please sign in to comment.