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

Commit

Permalink
Opprettet Application, Configuration og Builder
Browse files Browse the repository at this point in the history
Co-authored-by: Giao The Cung <[email protected]>
  • Loading branch information
mkjeldsr and gtcno committed Jan 4, 2024
1 parent 2387f29 commit c5a3614
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
14 changes: 13 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
plugins {

Check failure on line 1 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / Check coding style violations

[ktlint] reported by reviewdog 🐶 File must end with a newline (\n) Raw Output: build.gradle.kts:1:1: error: File must end with a newline (\n) (standard:final-newline)
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")
}
5 changes: 5 additions & 0 deletions src/main/kotlin/no/nav/dagpenger/regel/behovloser/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package no.nav.dagpenger.regel.behovloser

fun main() {
ApplicationBuilder(Configuration.config).start()
}
Original file line number Diff line number Diff line change
@@ -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<String, String>) : 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 {}
}
}
37 changes: 37 additions & 0 deletions src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt
Original file line number Diff line number Diff line change
@@ -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<String, String> =
properties.list().reversed().fold(emptyMap()) { map, pair ->
map + pair.second
}


Check failure on line 29 in src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt

View workflow job for this annotation

GitHub Actions / Check coding style violations

[ktlint] reported by reviewdog 🐶 Needless blank line(s) Raw Output: src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt:29:1: error: Needless blank line(s) (standard:no-consecutive-blank-lines)
// val azureAdClient by lazy {
// val azureAdConfig = OAuth2Config.AzureAd(properties)
// CachedOauth2Client(
// tokenEndpointUrl = azureAdConfig.tokenEndpointUrl,
// authType = azureAdConfig.clientSecret(),
// )
// }
}

0 comments on commit c5a3614

Please sign in to comment.