Skip to content

Commit

Permalink
move to init block
Browse files Browse the repository at this point in the history
  • Loading branch information
vendelieu committed Oct 6, 2024
1 parent 35505c0 commit 9bd0137
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/commonMain/kotlin/eu/vendeli/rethis/ReThis.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ class ReThis(
val logger = KtorSimpleLogger("eu.vendeli.rethis.ReThis")
internal val cfg: ClientConfiguration = ClientConfiguration().apply(configurator)
internal val rootJob = SupervisorJob()
internal val subscriptionHandlers = mutableMapOf<String, Job>()
internal val connectionPool by lazy { ConnectionPool(this, address.socket).also { it.prepare() } }

init {
logger.info("Created client (RESP $protocol)")

if (address is Url) {
cfg.db = address.db
if (address.credentials.isNotEmpty()) {
Expand All @@ -46,13 +50,6 @@ class ReThis(
}
}

internal val subscriptionHandlers = mutableMapOf<String, Job>()
internal val connectionPool by lazy { ConnectionPool(this, address.socket).also { it.prepare() } }

init {
logger.info("Created client (RESP $protocol)")
}

val subscriptions: Map<String, Job> get() = subscriptionHandlers
val isDisconnected: Boolean get() = connectionPool.isEmpty

Expand Down

0 comments on commit 9bd0137

Please sign in to comment.