From 55e8c481d18277af6c28a3329a7d2fa15e9d3611 Mon Sep 17 00:00:00 2001 From: Simon Vergauwen Date: Mon, 9 Jan 2023 12:12:22 +0100 Subject: [PATCH] Update to 1.8.0 (#2864) Co-authored-by: Alejandro Serrano --- .github/workflows/pull_request.yml | 3 --- .../kotlin/arrow/fx/coroutines/CircuitBreaker.kt | 15 +++++++-------- .../kotlin/arrow/fx/coroutines/Schedule.kt | 2 +- .../kotlin/examples/example-circuitbreaker-01.kt | 7 +++---- .../kotlin/examples/example-circuitbreaker-02.kt | 8 ++++---- .../kotlin/examples/example-schedule-08.kt | 2 +- gradle/libs.versions.toml | 4 ++-- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b6de70d8ae7..dccb7773060 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,9 +21,6 @@ jobs: distribution: 'zulu' java-version: 11 - - name: Install watchOS simulator - run: xcrun simctl create "Apple Watch Series 5 - 44mm" "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm" "com.apple.CoreSimulator.SimRuntime.watchOS-9-1" - - name: ios and watchos tests uses: gradle/gradle-build-action@v2 with: diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt index 81c991cde98..4cf59d0c681 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/CircuitBreaker.kt @@ -41,9 +41,8 @@ import kotlin.time.DurationUnit * * ```kotlin * import arrow.core.Either - * import arrow.core.flatten * import arrow.fx.coroutines.CircuitBreaker - * import kotlin.time.Duration + * import kotlin.time.Duration.Companion.seconds * import kotlin.time.ExperimentalTime * import kotlinx.coroutines.delay * @@ -52,9 +51,9 @@ import kotlin.time.DurationUnit * //sampleStart * val circuitBreaker = CircuitBreaker.of( * maxFailures = 2, - * resetTimeout = Duration.seconds(2), + * resetTimeout = 2.seconds, * exponentialBackoffFactor = 1.2, - * maxResetTimeout = Duration.seconds(60), + * maxResetTimeout = 60.seconds, * ) * circuitBreaker.protectOrThrow { "I am in Closed: ${circuitBreaker.state()}" }.also(::println) * @@ -99,9 +98,9 @@ import kotlin.time.DurationUnit * //sampleStart * val circuitBreaker = CircuitBreaker.of( * maxFailures = 2, - * resetTimeout = seconds(2), + * resetTimeout = 2.seconds, * exponentialBackoffFactor = 2.0, // enable exponentialBackoffFactor - * maxResetTimeout = seconds(60), // limit exponential back-off time + * maxResetTimeout = 60.seconds, // limit exponential back-off time * ) * * suspend fun resilient(schedule: Schedule, f: suspend () -> A): A = @@ -116,11 +115,11 @@ import kotlin.time.DurationUnit * * // Retry once and when the CircuitBreaker opens after 2 failures then retry with exponential back-off with same time as CircuitBreaker's resetTimeout * val fiveTimesWithBackOff = Schedule.recurs(1) andThen - * Schedule.exponential(seconds(2)) and Schedule.recurs(5) + * Schedule.exponential(2.seconds) and Schedule.recurs(5) * * Either.catch { * resilient(fiveTimesWithBackOff, ::apiCall) - * }.let { println("exponential(seconds(2)) and recurs(5) always retries with actual apiCall: $it") } + * }.let { println("exponential(2.seconds) and recurs(5) always retries with actual apiCall: $it") } * //sampleEnd * } * ``` diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt index 10d06ef1d28..246d38a2f44 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Schedule.kt @@ -192,7 +192,7 @@ import kotlin.time.DurationUnit.NANOSECONDS * A common algorithm to retry effectful operations, as network requests, is the exponential backoff algorithm. There is a scheduling policy that implements this algorithm and can be used as: * * ```kotlin - * import kotlin.time.milliseconds + * import kotlin.time.Duration.Companion.milliseconds * import kotlin.time.ExperimentalTime * import arrow.fx.coroutines.* * diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-01.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-01.kt index 20d6f11dd07..2fa0b9e43b3 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-01.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-01.kt @@ -2,9 +2,8 @@ package arrow.fx.coroutines.examples.exampleCircuitbreaker01 import arrow.core.Either -import arrow.core.flatten import arrow.fx.coroutines.CircuitBreaker -import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds import kotlin.time.ExperimentalTime import kotlinx.coroutines.delay @@ -12,9 +11,9 @@ import kotlinx.coroutines.delay suspend fun main(): Unit { val circuitBreaker = CircuitBreaker.of( maxFailures = 2, - resetTimeout = Duration.seconds(2), + resetTimeout = 2.seconds, exponentialBackoffFactor = 1.2, - maxResetTimeout = Duration.seconds(60), + maxResetTimeout = 60.seconds, ) circuitBreaker.protectOrThrow { "I am in Closed: ${circuitBreaker.state()}" }.also(::println) diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-02.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-02.kt index 978b08ec240..360172174c1 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-02.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-circuitbreaker-02.kt @@ -19,9 +19,9 @@ suspend fun main(): Unit { //sampleStart val circuitBreaker = CircuitBreaker.of( maxFailures = 2, - resetTimeout = seconds(2), + resetTimeout = 2.seconds, exponentialBackoffFactor = 2.0, // enable exponentialBackoffFactor - maxResetTimeout = seconds(60), // limit exponential back-off time + maxResetTimeout = 60.seconds, // limit exponential back-off time ) suspend fun resilient(schedule: Schedule, f: suspend () -> A): A = @@ -36,10 +36,10 @@ suspend fun main(): Unit { // Retry once and when the CircuitBreaker opens after 2 failures then retry with exponential back-off with same time as CircuitBreaker's resetTimeout val fiveTimesWithBackOff = Schedule.recurs(1) andThen - Schedule.exponential(seconds(2)) and Schedule.recurs(5) + Schedule.exponential(2.seconds) and Schedule.recurs(5) Either.catch { resilient(fiveTimesWithBackOff, ::apiCall) - }.let { println("exponential(seconds(2)) and recurs(5) always retries with actual apiCall: $it") } + }.let { println("exponential(2.seconds) and recurs(5) always retries with actual apiCall: $it") } //sampleEnd } diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-schedule-08.kt b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-schedule-08.kt index 52ea244a301..c333ee73f87 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-schedule-08.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-schedule-08.kt @@ -1,7 +1,7 @@ // This file was automatically generated from Schedule.kt by Knit tool. Do not edit. package arrow.fx.coroutines.examples.exampleSchedule08 -import kotlin.time.milliseconds +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.ExperimentalTime import arrow.fx.coroutines.* diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 02d36222a5d..19d8125c22a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,11 +11,11 @@ jUnitVintage = "5.8.2" kotest = "5.5.4" kotestGradle = "5.5.4" kover = "0.6.1" -kotlin = "1.7.22" +kotlin = "1.8.0" kotlinBinaryCompatibilityValidator = "0.12.1" kotlinCompileTesting = "1.4.9" knit = "0.4.0" -kspVersion = "1.7.22-1.0.8" +kspVersion = "1.8.0-1.0.8" kotlinxSerialization = "1.4.1" mockWebServer = "4.10.0" retrofit = "2.9.0"