improvements in startup launcher

This commit is contained in:
2022-12-25 10:26:44 +06:00
parent ee56e9543a
commit a83ee86340
6 changed files with 91 additions and 44 deletions

View File

@@ -1,10 +1,8 @@
package dev.inmo.micro_utils.startup.launcher
import dev.inmo.kslog.common.i
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin.setupDI
import kotlinx.serialization.json.JsonObject
import org.koin.core.KoinApplication
import org.koin.core.context.startKoin
import org.koin.dsl.module
/**
* Will create [KoinApplication], init, load modules using [StartLauncherPlugin] and start plugins using the same base
@@ -13,19 +11,7 @@ import org.koin.dsl.module
* @param rawConfig It is expected that this [JsonObject] will contain serialized [Config] ([StartLauncherPlugin] will
* deserialize it in its [StartLauncherPlugin.setupDI]
*/
@Deprecated("Fully replaced with StartLauncherPlugin#start", ReplaceWith("StartLauncherPlugin.start(rawConfig)", "dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin"))
suspend fun start(rawConfig: JsonObject) {
with(StartLauncherPlugin) {
logger.i("Start initialization")
val koinApp = KoinApplication.init()
koinApp.modules(
module {
setupDI(rawConfig)
}
)
logger.i("Modules loaded")
startKoin(koinApp)
logger.i("Koin started")
startPlugin(koinApp.koin)
logger.i("App has been setup")
}
StartLauncherPlugin.start(rawConfig)
}