Skip to content

Commit

Permalink
Update project config to keep correct dependencies for KTOR
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubos Horacek committed Jul 10, 2024
1 parent efbfa96 commit c8f58c2
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 10 deletions.
19 changes: 9 additions & 10 deletions search-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,24 @@ kotlin {
}
}

nativeMain {
iosMain {
dependencies {
implementation(Ktor.client.curl)
implementation(Ktor.client.darwin)
}
}

val iosX64Main by getting
val iosArm64Main by getting
// val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
// iosSimulatorArm64Main.dependsOn(this)
macosMain {
dependencies {
implementation(Ktor.client.darwin)
}
}

mingwMain {
dependencies {
implementation(Ktor.client.curl)
}
}

all {
languageSettings {
optIn("kotlin.RequiresOptIn")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.jillesvangurp.ktsearch

import com.jillesvangurp.serializationext.DEFAULT_JSON
import io.ktor.client.*
import io.ktor.client.plugins.auth.*
import io.ktor.client.plugins.auth.providers.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.logging.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*


import io.ktor.client.*
import io.ktor.client.engine.darwin.*

actual fun defaultKtorHttpClient(
logging: Boolean,
user: String?,
password: String?,
elasticApiKey: String?
): HttpClient {
return HttpClient(Darwin) {
engine {
pipelining = true
configureRequest {
setAllowsCellularAccess(true)
}
}
if(!user.isNullOrBlank() && !password.isNullOrBlank()) {
install(Auth) {
basic {
credentials {
BasicAuthCredentials(user, password)
}
sendWithoutRequest {
true
}
}
}
}
if(!elasticApiKey.isNullOrBlank()) {
headers {
append("Authorization", "ApiKey $elasticApiKey")
}
}
install(ContentNegotiation) {
json(DEFAULT_JSON)
}
if (logging) {
install(Logging) {
level = LogLevel.ALL
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.jillesvangurp.ktsearch

actual fun simpleIndexProvider(initialIndex: Int): IndexProvider = object : IndexProvider {
private var index = 0

override fun get(): Int = index

override fun set(value: Int) {
index = value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.jillesvangurp.ktsearch

/**
* On JVM this will return the current thread name, otherwise this will return null and pick a random node
*/
actual fun threadId(): String? = null

0 comments on commit c8f58c2

Please sign in to comment.