mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-03 22:29:30 +00:00
32 lines
1001 B
Kotlin
32 lines
1001 B
Kotlin
package dev.inmo.micro_utils.startup.launcher
|
|
|
|
import dev.inmo.kslog.common.i
|
|
import kotlinx.serialization.json.JsonObject
|
|
import org.koin.core.KoinApplication
|
|
import org.koin.core.context.GlobalContext
|
|
import org.koin.dsl.module
|
|
|
|
/**
|
|
* Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base
|
|
* plugin
|
|
*
|
|
* @param rawConfig It is expected that this [JsonObject] will contain serialized [Config] ([StartLauncherPlugin] will
|
|
* deserialize it in its [StartLauncherPlugin.setupDI]
|
|
*/
|
|
suspend fun start(rawConfig: JsonObject) {
|
|
with(StartLauncherPlugin) {
|
|
logger.i("Start initialization")
|
|
val koinApp = KoinApplication.init()
|
|
koinApp.modules(
|
|
module {
|
|
setupDI(rawConfig)
|
|
}
|
|
)
|
|
logger.i("Modules loaded")
|
|
GlobalContext.startKoin(koinApp)
|
|
logger.i("Koin started")
|
|
startPlugin(koinApp.koin)
|
|
logger.i("App has been setup")
|
|
}
|
|
}
|