-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from lhoracek/feature/ios_support
Add iOS targets
- Loading branch information
Showing
11 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
search-client/src/iosMain/kotlin/com/jillesvangurp/ktsearch/KtorRestClient.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
||
} | ||
} |
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions
56
search-client/src/macosMain/kotlin/com/jillesvangurp/ktsearch/KtorRestClient.macos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ch-client/src/macosMain/kotlin/com/jillesvangurp/ktsearch/RoundRobinNodeSelector.macos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
search-client/src/macosMain/kotlin/com/jillesvangurp/ktsearch/SniffingNodeSelector.macos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
...ch-client/src/mingwMain/kotlin/com/jillesvangurp/ktsearch/RoundRobinNodeSelector.mingw.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
search-client/src/mingwMain/kotlin/com/jillesvangurp/ktsearch/SniffingNodeSelector.mingw.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters