commonMain.com.algolia.client.transport.internal.RetryableHost.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algoliasearch-client-kotlin-jvm Show documentation
Show all versions of algoliasearch-client-kotlin-jvm Show documentation
"Algolia is a powerful search-as-a-service solution, made easy to use with API clients, UI libraries, and pre-built integrations. Algolia API Client for Kotlin lets you easily use the Algolia Search REST API from your JVM project, such as Android or backend implementations."
package com.algolia.client.transport.internal
import com.algolia.client.configuration.Host
/**
* This internal data class represents a host that supports retrying requests.
*
* It wraps a Host object and provides additional information about the host's status, such as
* whether it is up, when it was last updated, and how many times it has been retried.
*
* @property host The [Host] object that this RetryableHost is wrapping.
*/
internal data class RetryableHost(
private val host: Host,
) {
val url
get() = host.url
val protocol
get() = host.protocol
val port
get() = host.port
val callType
get() = host.callType
var isUp: Boolean = true
var lastUpdated: Long = currentTimeMillis()
var retryCount: Int = 0
fun reset() {
lastUpdated = currentTimeMillis()
isUp = true
retryCount = 0
}
fun hasTimedOut() {
isUp = true
lastUpdated = currentTimeMillis()
retryCount += 1
}
fun hasFailed() {
isUp = false
lastUpdated = currentTimeMillis()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy