Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test 1.8.0 on CI #2864

Merged
merged 11 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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)
*
Expand Down Expand Up @@ -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 <A> resilient(schedule: Schedule<Throwable, *>, f: suspend () -> A): A =
Expand All @@ -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<Throwable>(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
* }
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
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

@ExperimentalTime
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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <A> resilient(schedule: Schedule<Throwable, *>, f: suspend () -> A): A =
Expand All @@ -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<Throwable>(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
}
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down