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

Mark delay strategy components as deprecated #404

Merged
merged 3 commits into from
Sep 23, 2024
Merged
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
10 changes: 10 additions & 0 deletions coroutines/src/commonMain/kotlin/delay/DelayStrategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ import kotlin.time.TimeSource
/**
* Interface, using the strategy pattern, for an implementer to delay for periods of time.
*/
@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public interface DelayStrategy {

@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public suspend fun await(iteration: Int, elapsedMillis: Long)
}

/**
* [DelayStrategy] that, when [await] is called, will delay for a fixed amount of time, specified by [delayMillis].
*/
@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public class FixedDelay(
private val delayMillis: Long,
) : DelayStrategy {

@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
override suspend fun await(iteration: Int, elapsedMillis: Long) {
delay(delayMillis - elapsedMillis)
}
Expand Down Expand Up @@ -59,6 +65,7 @@ private const val DEFAULT_MAXIMUM_DELAY = Long.MAX_VALUE
* Inspired by:
* [Exponential Backoff And Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)
*/
@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public class ExponentialBackoff(
private val baseTimeMillis: Long = DEFAULT_BASE_TIME_MILLIS,
private val multiplier: Float = DEFAULT_MULTIPLIER,
Expand Down Expand Up @@ -103,17 +110,20 @@ internal fun getExponentialBackoffMillis(
* calculation (for the purposes of adjusting one DelayStrategy's delay based on the amount of time that passed in another
* DelayStrategy's delay).
*/
@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public class Dynamic<T> internal constructor(
private val trigger: Flow<T>,
private val timeSource: TimeSource,
private val selector: (T) -> DelayStrategy,
) : DelayStrategy {
@OptIn(ExperimentalTime::class)
@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
public constructor(
trigger: Flow<T>,
selector: (T) -> DelayStrategy,
) : this(trigger, Clock.System.asTimeSource(), selector)

@Deprecated("Use https://github.com/michaelbull/kotlin-retry instead.")
override suspend fun await(iteration: Int, elapsedMillis: Long) {
val mark = timeSource.markNow()
trigger
Expand Down
Loading