Skip to content

Commit

Permalink
Close connection to cache service properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Chelombitko committed Aug 2, 2024
1 parent 5a5a2d4 commit 95ea0ab
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions core/src/main/kotlin/com/malinskiy/marathon/Marathon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.malinskiy.marathon
import com.malinskiy.marathon.analytics.external.Analytics
import com.malinskiy.marathon.analytics.internal.pub.Track
import com.malinskiy.marathon.analytics.internal.sub.TrackerInternal
import com.malinskiy.marathon.cache.CacheService
import com.malinskiy.marathon.cache.test.CacheTestReporter
import com.malinskiy.marathon.cache.test.TestCacheLoader
import com.malinskiy.marathon.cache.test.TestCacheSaver
Expand Down Expand Up @@ -36,6 +37,7 @@ class Marathon(
private val deviceProvider: DeviceProvider,
private val tracker: TrackerInternal,
private val analytics: Analytics,
private val cacheService: CacheService,
private val testCacheLoader: TestCacheLoader,
private val testCacheSaver: TestCacheSaver,
private val testParser: TestParser,
Expand Down Expand Up @@ -74,6 +76,7 @@ class Marathon(
val currentCoroutineContext = coroutineContext
scheduler = Scheduler(
deviceProvider,
cacheService,
testCacheLoader,
testCacheSaver,
cachedTestsReporter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.malinskiy.marathon.cache

interface CacheService {
interface CacheService : AutoCloseable {
suspend fun load(key: CacheKey, reader: CacheEntryReader): Boolean
suspend fun store(key: CacheKey, writer: CacheEntryWriter)
fun close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,4 @@ class TestResultsCache(
track.cacheStore(start, finish, testResult.test)
}
}

fun terminate() {
cacheService.close()
}
}
2 changes: 1 addition & 1 deletion core/src/main/kotlin/com/malinskiy/marathon/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fun coreModule(timer: Timer?) = module {
single<Timer> { timer ?: SystemTimer(get()) }
single<ProgressReporter> { ProgressReporter(get()) }
single<StrictRunChecker> { ConfigurationStrictRunChecker(get()) }
single<Marathon> { Marathon(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) }
single<Marathon> { Marathon(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) }
}

fun KoinApplication.marathonConfiguration(configuration: Configuration): KoinApplication {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.malinskiy.marathon.execution

import com.malinskiy.marathon.analytics.external.Analytics
import com.malinskiy.marathon.analytics.internal.pub.Track
import com.malinskiy.marathon.cache.CacheService
import com.malinskiy.marathon.cache.test.CacheResult
import com.malinskiy.marathon.cache.test.CacheTestReporter
import com.malinskiy.marathon.cache.test.TestCacheLoader
Expand Down Expand Up @@ -37,6 +38,7 @@ import kotlin.coroutines.CoroutineContext

class Scheduler(
private val deviceProvider: DeviceProvider,
private val cacheService: CacheService,
private val cacheLoader: TestCacheLoader,
private val cacheSaver: TestCacheSaver,
private val cachedTestsReporter: CacheTestReporter,
Expand Down Expand Up @@ -103,6 +105,7 @@ class Scheduler(
}

cacheSaver.terminate()
cacheService.close()
}

suspend fun addTests(shard: TestShard) {
Expand Down

0 comments on commit 95ea0ab

Please sign in to comment.