mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-05-20 14:57:45 +00:00
Compare commits
12 Commits
0.15.0
...
b17931e7bd
| Author | SHA1 | Date | |
|---|---|---|---|
| b17931e7bd | |||
| 2a4570eafc | |||
| c9514d3a6d | |||
| 072805efc7 | |||
| 369ff26627 | |||
| c5abbbbd2d | |||
| d974639f1e | |||
| 26efde316b | |||
| fafe50f80a | |||
| 41504469db | |||
| 03b3ddd98b | |||
| 89d919f2be |
3
.github/workflows/dokka_push.yml
vendored
3
.github/workflows/dokka_push.yml
vendored
@@ -11,9 +11,6 @@ jobs:
|
|||||||
- uses: actions/setup-java@v1
|
- uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 11
|
||||||
- name: Fix android 32.0.0 dx
|
|
||||||
continue-on-error: true
|
|
||||||
run: cd /usr/local/lib/android/sdk/build-tools/32.0.0/ && mv d8 dx && cd lib && mv d8.jar dx.jar
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew build && ./gradlew dokkaHtml
|
run: ./gradlew build && ./gradlew dokkaHtml
|
||||||
- name: Publish KDocs
|
- name: Publish KDocs
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.15.1
|
||||||
|
|
||||||
## 0.15.0
|
## 0.15.0
|
||||||
|
|
||||||
* `Repos`:
|
* `Repos`:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ kotlin {
|
|||||||
// browser()
|
// browser()
|
||||||
// nodejs()
|
// nodejs()
|
||||||
// }
|
// }
|
||||||
android()
|
android {}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
@@ -30,8 +30,8 @@ kotlin {
|
|||||||
&& it.hasProperty("kotlin")
|
&& it.hasProperty("kotlin")
|
||||||
&& it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
||||||
// && it.kotlin.sourceSets.any { it.name.contains("jsMain") }
|
// && it.kotlin.sourceSets.any { it.name.contains("jsMain") }
|
||||||
// && it.kotlin.sourceSets.any { it.name.contains("jvmMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("jvmMain") }
|
||||||
// && it.kotlin.sourceSets.any { it.name.contains("androidMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("androidMain") }
|
||||||
) {
|
) {
|
||||||
api it
|
api it
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ kotlin {
|
|||||||
if (
|
if (
|
||||||
it != project
|
it != project
|
||||||
&& it.hasProperty("kotlin")
|
&& it.hasProperty("kotlin")
|
||||||
// && it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
||||||
&& it.kotlin.sourceSets.any { it.name.contains("jvmMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("jvmMain") }
|
||||||
) {
|
) {
|
||||||
api it
|
api it
|
||||||
@@ -78,7 +78,7 @@ kotlin {
|
|||||||
if (
|
if (
|
||||||
it != project
|
it != project
|
||||||
&& it.hasProperty("kotlin")
|
&& it.hasProperty("kotlin")
|
||||||
// && it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("commonMain") }
|
||||||
&& it.kotlin.sourceSets.any { it.name.contains("androidMain") }
|
&& it.kotlin.sourceSets.any { it.name.contains("androidMain") }
|
||||||
) {
|
) {
|
||||||
api it
|
api it
|
||||||
@@ -100,7 +100,7 @@ private List<SourceDirectorySet> findSourcesWithName(String... approximateNames)
|
|||||||
}.collect { it.kotlin }
|
}.collect { it.kotlin }
|
||||||
}
|
}
|
||||||
|
|
||||||
dokkaHtml {
|
tasks.dokkaHtml {
|
||||||
dokkaSourceSets {
|
dokkaSourceSets {
|
||||||
configureEach {
|
configureEach {
|
||||||
skipDeprecated.set(true)
|
skipDeprecated.set(true)
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.15.0
|
version=0.15.1
|
||||||
android_code_version=166
|
android_code_version=167
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ kt = "1.7.20"
|
|||||||
kt-serialization = "1.4.1"
|
kt-serialization = "1.4.1"
|
||||||
kt-coroutines = "1.6.4"
|
kt-coroutines = "1.6.4"
|
||||||
|
|
||||||
|
kslog = "0.5.4"
|
||||||
|
|
||||||
jb-compose = "1.2.1"
|
jb-compose = "1.2.1"
|
||||||
jb-exposed = "0.41.1"
|
jb-exposed = "0.41.1"
|
||||||
jb-dokka = "1.7.20"
|
jb-dokka = "1.7.20"
|
||||||
@@ -60,6 +62,7 @@ ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.re
|
|||||||
ktor-server-statusPages = { module = "io.ktor:ktor-server-status-pages", version.ref = "ktor" }
|
ktor-server-statusPages = { module = "io.ktor:ktor-server-status-pages", version.ref = "ktor" }
|
||||||
ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
|
ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
|
||||||
|
|
||||||
|
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
|
||||||
|
|
||||||
klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "klock" }
|
klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "klock" }
|
||||||
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
|
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.w3c.xhr.XMLHttpRequestResponseType
|
|||||||
* @param data [Map] where keys will be used as names for multipart parts and values as values. If you will pass
|
* @param data [Map] where keys will be used as names for multipart parts and values as values. If you will pass
|
||||||
* [dev.inmo.micro_utils.common.MPPFile] (File from JS or JVM platform). Also you may pass [UniUploadFileInfo] as value
|
* [dev.inmo.micro_utils.common.MPPFile] (File from JS or JVM platform). Also you may pass [UniUploadFileInfo] as value
|
||||||
* in case you wish to pass other source of multipart binary data than regular file
|
* in case you wish to pass other source of multipart binary data than regular file
|
||||||
|
* @suppress
|
||||||
*/
|
*/
|
||||||
actual suspend fun <T> HttpClient.uniUpload(
|
actual suspend fun <T> HttpClient.uniUpload(
|
||||||
url: String,
|
url: String,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.io.File
|
|||||||
* @param data [Map] where keys will be used as names for multipart parts and values as values. If you will pass
|
* @param data [Map] where keys will be used as names for multipart parts and values as values. If you will pass
|
||||||
* [dev.inmo.micro_utils.common.MPPFile] (File from JS or JVM platform). Also you may pass [UniUploadFileInfo] as value
|
* [dev.inmo.micro_utils.common.MPPFile] (File from JS or JVM platform). Also you may pass [UniUploadFileInfo] as value
|
||||||
* in case you wish to pass other source of multipart binary data than regular file
|
* in case you wish to pass other source of multipart binary data than regular file
|
||||||
|
* @suppress
|
||||||
*/
|
*/
|
||||||
actual suspend fun <T> HttpClient.uniUpload(
|
actual suspend fun <T> HttpClient.uniUpload(
|
||||||
url: String,
|
url: String,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ kotlin {
|
|||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
implementation libs.kt.serialization
|
api libs.kt.serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commonTest {
|
commonTest {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ kotlin {
|
|||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
implementation libs.kt.serialization
|
api libs.kt.serialization
|
||||||
implementation compose.runtime
|
implementation compose.runtime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ String[] includes = [
|
|||||||
":serialization:base64",
|
":serialization:base64",
|
||||||
":serialization:encapsulator",
|
":serialization:encapsulator",
|
||||||
":serialization:typed_serializer",
|
":serialization:typed_serializer",
|
||||||
|
":startup:plugin",
|
||||||
|
":startup:launcher",
|
||||||
|
|
||||||
":fsm:common",
|
":fsm:common",
|
||||||
":fsm:repos:common",
|
":fsm:repos:common",
|
||||||
|
|||||||
16
startup/launcher/build.gradle
Normal file
16
startup/launcher/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJavaProjectPresetPath"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api internalProject("micro_utils.startup.plugin")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
startup/launcher/src/commonMain/kotlin/Config.kt
Normal file
9
startup/launcher/src/commonMain/kotlin/Config.kt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.startup.plugin.ServerPlugin
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Config(
|
||||||
|
val plugins: List<ServerPlugin>
|
||||||
|
)
|
||||||
7
startup/launcher/src/commonMain/kotlin/DefaultJson.kt
Normal file
7
startup/launcher/src/commonMain/kotlin/DefaultJson.kt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
val defaultJson = Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
}
|
||||||
57
startup/launcher/src/commonMain/kotlin/StartupLauncher.kt
Normal file
57
startup/launcher/src/commonMain/kotlin/StartupLauncher.kt
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.i
|
||||||
|
import dev.inmo.kslog.common.taggedLogger
|
||||||
|
import dev.inmo.kslog.common.w
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
|
import dev.inmo.micro_utils.startup.plugin.ServerPlugin
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.joinAll
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import org.koin.core.Koin
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
object StartupLauncher : ServerPlugin {
|
||||||
|
internal val logger = taggedLogger(this)
|
||||||
|
override fun Module.setupDI(config: JsonObject) {
|
||||||
|
val pluginsConfig = defaultJson.decodeFromJsonElement(Config.serializer(), config)
|
||||||
|
|
||||||
|
single { pluginsConfig }
|
||||||
|
single { CoroutineScope(Dispatchers.Default) }
|
||||||
|
|
||||||
|
includes(
|
||||||
|
pluginsConfig.plugins.mapNotNull {
|
||||||
|
runCatching {
|
||||||
|
module {
|
||||||
|
with(it) {
|
||||||
|
setupDI(config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.onFailure { e ->
|
||||||
|
logger.w("Unable to load DI part of $it", e)
|
||||||
|
}.getOrNull()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun startPlugin(koin: Koin) {
|
||||||
|
val scope = koin.get<CoroutineScope>()
|
||||||
|
koin.get<Config>().plugins.map { plugin ->
|
||||||
|
scope.launch {
|
||||||
|
runCatchingSafely {
|
||||||
|
logger.i("Start loading of $plugin")
|
||||||
|
with(plugin) {
|
||||||
|
startPlugin(koin)
|
||||||
|
}
|
||||||
|
}.onFailure { e ->
|
||||||
|
logger.w("Unable to load bot part of $plugin", e)
|
||||||
|
}.onSuccess {
|
||||||
|
logger.i("Complete loading of $plugin")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.joinAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
36
startup/launcher/src/jvmMain/kotlin/ServerLauncher.kt
Normal file
36
startup/launcher/src/jvmMain/kotlin/ServerLauncher.kt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package dev.inmo.micro_utils.startup.launcher
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.KSLog
|
||||||
|
import dev.inmo.kslog.common.i
|
||||||
|
import dev.inmo.micro_utils.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import org.koin.core.KoinApplication
|
||||||
|
import org.koin.core.context.GlobalContext
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
suspend fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
KSLog.default = KSLog("ServerLauncher")
|
||||||
|
val (configPath) = args
|
||||||
|
val file = File(configPath)
|
||||||
|
KSLog.i("Start read config from ${file.absolutePath}")
|
||||||
|
val json = defaultJson.parseToJsonElement(file.readText()).jsonObject
|
||||||
|
KSLog.i("Config has been read")
|
||||||
|
|
||||||
|
with(StartupLauncher) {
|
||||||
|
logger.i("Start initialization")
|
||||||
|
val koinApp = KoinApplication.init()
|
||||||
|
koinApp.modules(
|
||||||
|
module {
|
||||||
|
setupDI(json)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
logger.i("Modules loaded")
|
||||||
|
GlobalContext.startKoin(koinApp)
|
||||||
|
logger.i("Koin started")
|
||||||
|
startPlugin(koinApp.koin)
|
||||||
|
logger.i("Behaviour builder has been setup")
|
||||||
|
}
|
||||||
|
}
|
||||||
19
startup/plugin/build.gradle
Normal file
19
startup/plugin/build.gradle
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$mppJavaProjectPresetPath"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
api libs.koin
|
||||||
|
api libs.kt.serialization
|
||||||
|
api libs.kslog
|
||||||
|
api project(":micro_utils.coroutines")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
startup/plugin/src/commonMain/kotlin/ServerPlugin.kt
Normal file
34
startup/plugin/src/commonMain/kotlin/ServerPlugin.kt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package dev.inmo.micro_utils.startup.plugin
|
||||||
|
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import org.koin.core.Koin
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
|
||||||
|
@Serializable(ServerPlugin.Companion::class)
|
||||||
|
interface ServerPlugin {
|
||||||
|
fun Module.setupDI(config: JsonObject) {}
|
||||||
|
|
||||||
|
suspend fun startPlugin(koin: Koin) {}
|
||||||
|
|
||||||
|
companion object : KSerializer<ServerPlugin> {
|
||||||
|
override val descriptor: SerialDescriptor
|
||||||
|
get() = String.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): ServerPlugin {
|
||||||
|
val kclass = Class.forName(decoder.decodeString()).kotlin
|
||||||
|
return (kclass.objectInstance ?: kclass.constructors.first { it.parameters.isEmpty() }.call()) as ServerPlugin
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: ServerPlugin) {
|
||||||
|
encoder.encodeString(
|
||||||
|
value::class.java.canonicalName
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user