This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
generated from navikt/dp-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Opprettet Application, Configuration og Builder
Co-authored-by: Giao The Cung <[email protected]>
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/no/nav/dagpenger/regel/behovloser/ApplicationBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
src/main/kotlin/no/nav/dagpenger/regel/behovloser/Configuration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / Check coding style violations
|
||
// val azureAdClient by lazy { | ||
// val azureAdConfig = OAuth2Config.AzureAd(properties) | ||
// CachedOauth2Client( | ||
// tokenEndpointUrl = azureAdConfig.tokenEndpointUrl, | ||
// authType = azureAdConfig.clientSecret(), | ||
// ) | ||
// } | ||
} |