diff --git a/build.gradle.kts b/build.gradle.kts index c795a5f..3c498c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,16 @@ plugins { id("common") - `java-library` + application } +repositories { + mavenCentral() + maven("https://github-package-registry-mirror.gc.nav.no/cached/maven-release") +} +dependencies { + implementation(libs.kotlin.logging) + implementation(libs.rapids.and.rivers) + implementation(libs.konfig) +} +application { + mainClass.set("no.nav.dagpenger.regel.behovloser.AppKt") +} \ No newline at end of file diff --git a/src/main/kotlin/no/nav/dagpenger/regel/behovloser/App.kt b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/App.kt new file mode 100644 index 0000000..61b3093 --- /dev/null +++ b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/App.kt @@ -0,0 +1,5 @@ +package no.nav.dagpenger.regel.behovloser + +fun main() { + ApplicationBuilder(Configuration.config).start() +} diff --git a/src/main/kotlin/no/nav/dagpenger/regel/behovloser/ApplicationBuilder.kt b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/ApplicationBuilder.kt new file mode 100644 index 0000000..ed94d1f --- /dev/null +++ b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/ApplicationBuilder.kt @@ -0,0 +1,31 @@ +package no.nav.dagpenger.regel.behovloser + +import mu.KotlinLogging +import no.nav.helse.rapids_rivers.RapidApplication +import no.nav.helse.rapids_rivers.RapidsConnection + +internal class ApplicationBuilder(configuration: Map) : RapidsConnection.StatusListener { + private val rapidsConnection: RapidsConnection = + RapidApplication.Builder(RapidApplication.RapidApplicationConfig.fromEnv(configuration)).build() + + init { + rapidsConnection.register(this) + } + + fun start() { + rapidsConnection.start() + } + + override fun onStartup(rapidsConnection: RapidsConnection) { + // clean() + logger.info { "Starter appen ${Configuration.APP_NAME}" } + } + + override fun onShutdown(rapidsConnection: RapidsConnection) { + logger.info { "Skrur av applikasjonen" } + } + + private companion object { + private val logger = KotlinLogging.logger {} + } +} diff --git a/src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt new file mode 100644 index 0000000..4113f38 --- /dev/null +++ b/src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt @@ -0,0 +1,37 @@ +package no.nav.dagpenger.regel.behovloser + +import com.natpryce.konfig.ConfigurationMap +import com.natpryce.konfig.ConfigurationProperties +import com.natpryce.konfig.EnvironmentVariables +import com.natpryce.konfig.overriding + +internal object Configuration { + const val APP_NAME = "dp-regel-behovloser" + + private val defaultProperties = + ConfigurationMap( + mapOf( + "RAPID_APP_NAME" to APP_NAME, + "KAFKA_CONSUMER_GROUP_ID" to "dp-regel-behovloser-v1", + "KAFKA_RAPID_TOPIC" to "teamdagpenger.regel.v1", + "KAFKA_EXTRA_TOPIC" to "teamdagpenger.rapid.v1", + "KAFKA_RESET_POLICY" to "latest", + ), + ) + val properties = + ConfigurationProperties.systemProperties() overriding EnvironmentVariables() overriding defaultProperties + + val config: Map = + properties.list().reversed().fold(emptyMap()) { map, pair -> + map + pair.second + } + + +// val azureAdClient by lazy { +// val azureAdConfig = OAuth2Config.AzureAd(properties) +// CachedOauth2Client( +// tokenEndpointUrl = azureAdConfig.tokenEndpointUrl, +// authType = azureAdConfig.clientSecret(), +// ) +// } +}