File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
src/main/kotlin/com/cognifide/gradle/environment Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11package com.cognifide.gradle.environment
22
33import com.cognifide.gradle.common.CommonExtension
4+ import com.cognifide.gradle.common.build.Retry
45import com.cognifide.gradle.common.utils.using
56import com.cognifide.gradle.environment.docker.Docker
67import com.cognifide.gradle.environment.health.HealthChecker
@@ -100,14 +101,17 @@ open class EnvironmentExtension(val project: Project) : Serializable {
100101 logger.info(" Destroyed: $this " )
101102 }
102103
103- fun check (verbose : Boolean = true): List <HealthStatus > {
104+ fun check (verbose : Boolean = true, retry : Retry ? = null ): List <HealthStatus > {
104105 if (! up) {
105106 throw EnvironmentException (" Cannot check environment as it is not up!" )
106107 }
107108
108109 logger.info(" Checking $this " )
109110
110- return healthChecker.check(verbose)
111+ return when {
112+ retry != null -> healthChecker.check(verbose, retry)
113+ else -> healthChecker.check(verbose)
114+ }
111115 }
112116
113117 fun reload () {
Original file line number Diff line number Diff line change 11package com.cognifide.gradle.environment.health
22
3+ import com.cognifide.gradle.common.build.Retry
34import com.cognifide.gradle.common.http.HttpClient
45import com.cognifide.gradle.common.utils.Formats
56import com.cognifide.gradle.environment.EnvironmentExtension
@@ -27,7 +28,7 @@ class HealthChecker(val environment: EnvironmentExtension) {
2728 }
2829 }
2930
30- var retry = common.retry { afterSquaredSecond(prop.long(" environment.health.retry" ) ? : 6 ) }
31+ var retry = common.retry { afterSquaredSecond(prop.long(" environment.health.retry" ) ? : 7 ) }
3132
3233 fun check (name : String , check : () -> Unit ) {
3334 checks + = HealthCheck (name, check)
@@ -38,7 +39,7 @@ class HealthChecker(val environment: EnvironmentExtension) {
3839 // Evaluation
3940
4041 @Suppress(" ComplexMethod" )
41- fun check (verbose : Boolean = true): List <HealthStatus > {
42+ fun check (verbose : Boolean = true, retry : Retry = this.retry ): List <HealthStatus > {
4243 var all = listOf<HealthStatus >()
4344 var passed = listOf<HealthStatus >()
4445 var failed = listOf<HealthStatus >()
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import kotlinx.coroutines.channels.Channel
88import kotlinx.coroutines.channels.ReceiveChannel
99import java.util.*
1010
11- @UseExperimental (ObsoleteCoroutinesApi ::class )
11+ @OptIn (ObsoleteCoroutinesApi ::class )
1212open class Reloader (val environment : EnvironmentExtension ) {
1313
1414 private val common = environment.common
@@ -25,6 +25,8 @@ open class Reloader(val environment: EnvironmentExtension) {
2525
2626 val configured get() = watchedContainers.isNotEmpty()
2727
28+ val retry = common.retry { afterSquaredSecond(common.prop.long(" environment.reloader.retry" ) ? : 3 ) }
29+
2830 fun start () {
2931 runBlocking {
3032 watchContainerFileChanges()
@@ -76,7 +78,7 @@ open class Reloader(val environment: EnvironmentExtension) {
7678 private fun CoroutineScope.checkHealthAfterReload () = launch {
7779 while (true ) {
7880 healthCheckRequests.receiveAvailable()
79- environment.check(false )
81+ environment.check(false , retry )
8082 }
8183 }
8284
You can’t perform that action at this time.
0 commit comments