Skip to content

Commit 896d65e

Browse files
committed
release 1.5.1
2 parents cf8b01c + 5bcbf3f commit 896d65e

File tree

25 files changed

+157
-55
lines changed

25 files changed

+157
-55
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 1.5.1
2+
3+
### Fixed
4+
- AB testing average click pos type from `Int` to `Float`
5+
- Transport layer timeouts
6+
7+
### Changed
8+
- Update Ktor to 1.4.1 transitively Kotlin serialization to `1.0.0-RC2`
9+
110
# 1.5.0
211

312
### Added

buildSrc/src/main/kotlin/Ktor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ object Ktor : Dependency {
22

33
override val group = "io.ktor"
44
override val artifact = "ktor"
5-
override val version = "1.4.0"
5+
override val version = "1.4.1"
66
}

buildSrc/src/main/kotlin/Library.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ object Library : Dependency {
22

33
override val group = "com.algolia"
44
override val artifact = "algoliasearch-client-kotlin"
5-
override val version = "1.5.0"
5+
override val version = "1.5.1"
66
}

src/commonMain/kotlin/com/algolia/search/client/ClientAccount.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public object ClientAccount {
2828
try {
2929
destination.getSettings()
3030
} catch (exception: ResponseException) {
31-
hasThrown404 = exception.response?.status?.value == HttpStatusCode.NotFound.value
31+
hasThrown404 = exception.response.status.value == HttpStatusCode.NotFound.value
3232
if (!hasThrown404) throw exception
3333
}
3434
if (!hasThrown404) {

src/commonMain/kotlin/com/algolia/search/client/internal/ClientSearchImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal class ClientSearchImpl internal constructor(
9696
try {
9797
return getAPIKey(apiKey)
9898
} catch (exception: ResponseException) {
99-
if (exception.response?.status?.value != HttpStatusCode.NotFound.value) throw exception
99+
if (exception.response.status.value != HttpStatusCode.NotFound.value) throw exception
100100
}
101101
delay(1000L)
102102
}
@@ -118,7 +118,7 @@ internal class ClientSearchImpl internal constructor(
118118
try {
119119
getAPIKey(apiKey)
120120
} catch (exception: ResponseException) {
121-
if (exception.response?.status?.value == HttpStatusCode.NotFound.value) return true else throw exception
121+
if (exception.response.status.value == HttpStatusCode.NotFound.value) return true else throw exception
122122
}
123123
delay(1000L)
124124
}

src/commonMain/kotlin/com/algolia/search/configuration/internal/extension/HttpClient.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.algolia.search.configuration.clientUserAgent
77
import com.algolia.search.serialize.internal.JsonNonStrict
88
import io.ktor.client.HttpClient
99
import io.ktor.client.HttpClientConfig
10+
import io.ktor.client.features.HttpTimeout
1011
import io.ktor.client.features.UserAgent
1112
import io.ktor.client.features.defaultRequest
1213
import io.ktor.client.features.json.JsonFeature
@@ -35,6 +36,7 @@ internal fun HttpClientConfig<*>.configure(configuration: Configuration) {
3536
install(UserAgent) {
3637
agent = clientUserAgent(AlgoliaSearchClient.version)
3738
}
39+
install(HttpTimeout)
3840
defaultRequest {
3941
configuration.defaultHeaders?.let {
4042
it.forEach { (key, value) -> header(key, value) }

src/commonMain/kotlin/com/algolia/search/endpoint/internal/EndpointIndex.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal class EndpointIndexImpl(
6868
try {
6969
EndpointSearch(transport, indexName).search(Query(responseFields = emptyList()))
7070
} catch (exception: ResponseException) {
71-
if (exception.response?.status == HttpStatusCode.NotFound) return false
71+
if (exception.response.status == HttpStatusCode.NotFound) return false
7272
}
7373
return true
7474
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.algolia.search.exception
2+
3+
/**
4+
* Exception thrown when an error occurs during the Serialization/Deserialization process.
5+
*/
6+
public sealed class AlgoliaRuntimeException(message: String? = null, cause: Throwable? = null) :
7+
RuntimeException(message, cause)
8+
9+
/**
10+
* Exception thrown when all hosts are unreachable.
11+
* When several errors occurred, use the last one as the cause for the returned exception.
12+
*
13+
* @param exceptions list of thrown exceptions
14+
*/
15+
public class UnreachableHostsException(
16+
public val exceptions: List<Throwable>,
17+
) : AlgoliaRuntimeException("Unreachable Hosts", exceptions.last()) {
18+
19+
public constructor(vararg exceptions: Throwable) : this(exceptions.toList())
20+
}

src/commonMain/kotlin/com/algolia/search/helper/ResponseException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import io.ktor.utils.io.core.String
88
* Convenience method to convert [ResponseException.response] body bytes to a [String].
99
*/
1010
public suspend fun ResponseException.readContent(): String? {
11-
return response?.readBytes()?.let { String(it) }
11+
return String(response.readBytes())
1212
}

src/commonMain/kotlin/com/algolia/search/model/response/ResponseVariant.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public data class ResponseVariant(
4242
/**
4343
* Average click position for the variant.
4444
*/
45-
@SerialName(KeyAverageClickPosition) val averageClickPositionOrNull: Int? = null,
45+
@SerialName(KeyAverageClickPosition) val averageClickPositionOrNull: Float? = null,
4646
@SerialName(KeySearchCount) val searchCountOrNull: Long? = null,
4747
@SerialName(KeyTrackedSearchCount) val trackedSearchCountOrNull: Long? = null,
4848
@SerialName(KeyUserCount) val userCountOrNull: Long? = null,
@@ -59,7 +59,7 @@ public data class ResponseVariant(
5959
public val noResultCount: Int
6060
get() = noResultCountOrNull!!
6161

62-
public val averageClickPosition: Int
62+
public val averageClickPosition: Float
6363
get() = averageClickPositionOrNull!!
6464

6565
public val searchCount: Long

0 commit comments

Comments
 (0)