Skip to content

Commit

Permalink
Eksperiment: Bygg Redis-URI selv
Browse files Browse the repository at this point in the history
  • Loading branch information
bjerga committed Jan 16, 2025
1 parent bc6b519 commit 82e6e92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ object Routes {

fun main() {
val rapid = RapidApplication.create(System.getenv())
val aivenRedisConnection = RedisConnection(Env.Redis.aivenUri + "/0")
val aivenRedisConnection =
RedisConnection(
Env.Redis.aivenHost,
Env.Redis.aivenPassword,
Env.Redis.aivenPort,
)
val redisConnection = RedisConnection(Env.Redis.url)

embeddedServer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ object Env {
}

object Redis {
val aivenUri: String = "REDIS_URI_INNTEKTSMELDING".fromEnv()
val aivenHost: String = "REDIS_HOST_INNTEKTSMELDING".fromEnv()
val aivenPassword: String = "REDIS_PASSWORD_INNTEKTSMELDING".fromEnv()
val aivenPort: String = "REDIS_PORT_INNTEKTSMELDING".fromEnv()

// val aivenUri: String = "REDIS_URI_INNTEKTSMELDING".fromEnv()
val url: String = "REDIS_URL".fromEnv()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import no.nav.helsearbeidsgiver.utils.collection.mapValuesNotNull
class RedisConnection(
redisUri: String,
) {
constructor(
aivenHost: String,
aivenPassword: String,
aivenPort: String,
) : this("rediss://$aivenPassword@$aivenHost:$aivenPort/0")

private val client: RedisClient = RedisClient.create(redisUri)
private val connection: StatefulRedisConnection<String, String> = client.connect()
private val syncCommands: RedisCommands<String, String> = connection.sync()
Expand Down

0 comments on commit 82e6e92

Please sign in to comment.