Module templates refactoring
This commit is contained in:
parent
a991b87158
commit
78f6752598
@ -22,7 +22,7 @@ public interface CreateModuleScope<mUE : Any, RUNTIME_KEY : Any> {
|
|||||||
|
|
||||||
public fun moduleScopedObject(namespace: Namespace<mUE, RUNTIME_KEY> = this.rootNs, name: String): ModuleScopedObject<mUE, RUNTIME_KEY>
|
public fun moduleScopedObject(namespace: Namespace<mUE, RUNTIME_KEY> = this.rootNs, name: String): ModuleScopedObject<mUE, RUNTIME_KEY>
|
||||||
|
|
||||||
public fun <mUE : Any> substituteModule(rootNs: Namespace<mUE, RUNTIME_KEY>, template: ModuleTemplate<mUE>): Module<mUE, RUNTIME_KEY>
|
public fun <mUE : Any> substituteModule(rootNs: Namespace<mUE, RUNTIME_KEY>, template: Module.Template<mUE>): Module<mUE, RUNTIME_KEY>
|
||||||
|
|
||||||
public fun namespace(parent: Namespace<mUE, RUNTIME_KEY>, name: String): Namespace<mUE, RUNTIME_KEY>
|
public fun namespace(parent: Namespace<mUE, RUNTIME_KEY>, name: String): Namespace<mUE, RUNTIME_KEY>
|
||||||
|
|
||||||
|
@ -2,13 +2,12 @@ package ru.landgrafhomyak.db.sql_skeleton_0.api.module
|
|||||||
|
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.DebugApi
|
import ru.landgrafhomyak.db.sql_skeleton_0.api.DebugApi
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.queries._Statement
|
import ru.landgrafhomyak.db.sql_skeleton_0.api.LowLevelApi
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.runtime.Executor
|
import ru.landgrafhomyak.db.sql_skeleton_0.api.queries.QueriesCompiler
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.table.Table
|
import ru.landgrafhomyak.db.sql_skeleton_0.api.runtime.Transaction
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.table.TableConstructor
|
|
||||||
|
|
||||||
|
|
||||||
public interface Module<mUE : Any, RUNTIME_KEY: Any> {
|
public interface Module<mUE : Any, RUNTIME_KEY : Any> {
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("uExt")
|
@get:JvmName("uExt")
|
||||||
public val uExt: mUE
|
public val uExt: mUE
|
||||||
@ -22,4 +21,32 @@ public interface Module<mUE : Any, RUNTIME_KEY: Any> {
|
|||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("getParent")
|
@get:JvmName("getParent")
|
||||||
public val parent: Module<*, RUNTIME_KEY>?
|
public val parent: Module<*, RUNTIME_KEY>?
|
||||||
|
|
||||||
|
public interface Constructor<mUE : Any, RUNTIME_KEY : Any> {
|
||||||
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
|
@get:JvmName("versionKey")
|
||||||
|
public val versionKey: String
|
||||||
|
|
||||||
|
public fun createSchema(context: CreateModuleScope<mUE, RUNTIME_KEY>): mUE
|
||||||
|
|
||||||
|
public suspend fun initData(ext: mUE, compiler: QueriesCompiler<RUNTIME_KEY>, transaction: Transaction<RUNTIME_KEY>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Upgrade<omUE : Any, nmUE : Any, RUNTIME_KEY : Any> {
|
||||||
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
|
@get:JvmName("versionKey")
|
||||||
|
public val versionKey: String
|
||||||
|
|
||||||
|
public fun upgradeSchema(context: UpgradeModuleScope<nmUE, omUE, RUNTIME_KEY>): nmUE
|
||||||
|
|
||||||
|
public suspend fun upgradeData(ext: nmUE, compiler: QueriesCompiler<RUNTIME_KEY>, transaction: Transaction<RUNTIME_KEY>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Template<@Suppress("unused") mUE : Any> {
|
||||||
|
@LowLevelApi
|
||||||
|
public fun <RUNTIME_KEY : Any> getConstructor(): Constructor<*, RUNTIME_KEY>
|
||||||
|
|
||||||
|
@LowLevelApi
|
||||||
|
public fun <RUNTIME_KEY : Any> getUpgrade(version: String): Upgrade<*, *, RUNTIME_KEY>?
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,51 +0,0 @@
|
|||||||
package ru.landgrafhomyak.db.sql_skeleton_0.api.module
|
|
||||||
|
|
||||||
import kotlin.jvm.JvmName
|
|
||||||
import ru.landgrafhomyak.db.sql_skeleton_0.api.runtime.Transaction
|
|
||||||
|
|
||||||
public interface ModuleTemplate<@Suppress("unused") mUE : Any> {
|
|
||||||
public interface VersionsInitializer<UE : Any> {
|
|
||||||
public fun createModuleTemplates(context: Scope): UE
|
|
||||||
|
|
||||||
public interface Scope {
|
|
||||||
public fun <nmUE : Any> createTemplate(
|
|
||||||
constructor: ModuleConstructor<nmUE>,
|
|
||||||
): ModuleTemplate<nmUE>
|
|
||||||
|
|
||||||
public fun <omUE : Any, nmUE : Any> upgradeTemplate(
|
|
||||||
oldModule: ModuleTemplate<omUE>,
|
|
||||||
upgrade: ModuleUpgrade<omUE, nmUE>,
|
|
||||||
): ModuleTemplate<nmUE>
|
|
||||||
|
|
||||||
public fun <omUE : Any, nmUE : Any> upgradeTemplateAndMerge(
|
|
||||||
oldModule: ModuleTemplate<omUE>,
|
|
||||||
upgrade: ModuleUpgrade<omUE, nmUE>,
|
|
||||||
mergeTo: ModuleTemplate<nmUE>
|
|
||||||
): ModuleTemplate<nmUE>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ModuleConstructor<mUE : Any> {
|
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
|
||||||
@get:JvmName("versionKey")
|
|
||||||
public val versionKey: String
|
|
||||||
|
|
||||||
public fun createSchema(context: CreateModuleScope): mUE
|
|
||||||
|
|
||||||
public suspend fun initData(ext: mUE, transaction: Transaction) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ModuleUpgrade<omUE : Any, nmUE : Any> {
|
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
|
||||||
@get:JvmName("versionKey")
|
|
||||||
public val versionKey: String
|
|
||||||
|
|
||||||
public fun upgradeSchema(context: UpgradeModuleScope<omUE>): nmUE
|
|
||||||
|
|
||||||
public suspend fun upgradeData(ext: nmUE, transaction: Transaction) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
|
||||||
@get:JvmName("getVersionKey")
|
|
||||||
public val versionKey: String
|
|
||||||
}
|
|
@ -56,8 +56,8 @@ public interface UpgradeModuleScope<nmUE : Any, omUE : Any, RUNTIME_KEY : Any> :
|
|||||||
public fun <smUE : Any> keepModule(module: Module<smUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
public fun <smUE : Any> keepModule(module: Module<smUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
||||||
public fun <smUE : Any> keepAndMoveModule(oldModule: Module<smUE, RUNTIME_KEY>, newNs: Namespace<nmUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
public fun <smUE : Any> keepAndMoveModule(oldModule: Module<smUE, RUNTIME_KEY>, newNs: Namespace<nmUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
||||||
|
|
||||||
public fun <smUE : Any> upgradeModule(oldModule: Module<*, RUNTIME_KEY>, template: ModuleTemplate<smUE>): Module<smUE, RUNTIME_KEY>
|
public fun <smUE : Any> upgradeModule(oldModule: Module<*, RUNTIME_KEY>, template: Module.Template<smUE>): Module<smUE, RUNTIME_KEY>
|
||||||
public fun <smUE : Any> upgradeAndMoveModule(oldModule: Module<*, RUNTIME_KEY>, newNs: Namespace<nmUE, RUNTIME_KEY>, template: ModuleTemplate<smUE>): Module<smUE, RUNTIME_KEY>
|
public fun <smUE : Any> upgradeAndMoveModule(oldModule: Module<*, RUNTIME_KEY>, newNs: Namespace<nmUE, RUNTIME_KEY>, template: Module.Template<smUE>): Module<smUE, RUNTIME_KEY>
|
||||||
|
|
||||||
public fun removeModule(oldModule: Module<*, RUNTIME_KEY>)
|
public fun removeModule(oldModule: Module<*, RUNTIME_KEY>)
|
||||||
public fun <smUE : Any> removeModuleAfterUpgrade(oldModule: Module<smUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
public fun <smUE : Any> removeModuleAfterUpgrade(oldModule: Module<smUE, RUNTIME_KEY>): Module<smUE, RUNTIME_KEY>
|
||||||
|
Loading…
Reference in New Issue
Block a user