-
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 #152 from szaffarano/szaffarano/linux-support
Add support for Linux platform
- Loading branch information
Showing
7 changed files
with
95 additions
and
29 deletions.
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
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 |
---|---|---|
|
@@ -32,3 +32,7 @@ secring.gpg | |
local.properties | ||
localRepo | ||
.ipynb_checkpoints | ||
.direnv | ||
flake.nix | ||
flake.lock | ||
.envrc |
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
37 changes: 37 additions & 0 deletions
37
search-client/src/linuxMain/kotlin/com/jillesvangurp/ktsearch/KtorRestClient.linux.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,37 @@ | ||
package com.jillesvangurp.ktsearch | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.curl.Curl | ||
import io.ktor.client.plugins.auth.Auth | ||
import io.ktor.client.plugins.auth.providers.BasicAuthCredentials | ||
import io.ktor.client.plugins.auth.providers.basic | ||
import io.ktor.client.plugins.logging.LogLevel | ||
import io.ktor.client.plugins.logging.Logging | ||
import io.ktor.http.headers | ||
|
||
actual fun defaultKtorHttpClient( | ||
logging: Boolean, | ||
user: String?, | ||
password: String?, | ||
elasticApiKey: String? | ||
): HttpClient { | ||
return HttpClient(Curl) { | ||
engine { | ||
pipelining = true | ||
} | ||
if (!user.isNullOrBlank() && !password.isNullOrBlank()) { | ||
install(Auth) { | ||
basic { | ||
credentials { BasicAuthCredentials(user, password) } | ||
sendWithoutRequest { true } | ||
} | ||
} | ||
} | ||
if (!elasticApiKey.isNullOrBlank()) { | ||
headers { append("Authorization", "ApiKey $elasticApiKey") } | ||
} | ||
if (logging) { | ||
install(Logging) { level = LogLevel.ALL } | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ch-client/src/linuxMain/kotlin/com/jillesvangurp/ktsearch/RoundRobinNodeSelector.linux.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/linuxMain/kotlin/com/jillesvangurp/ktsearch/SniffingNodeSelector.linux.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