Improved interface for connection entrypoint
This commit is contained in:
parent
7ca7f9878e
commit
306bf7c971
@ -2,7 +2,7 @@ package ru.landgrafhomyak.db.serdha0.api.module
|
|||||||
|
|
||||||
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
||||||
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
||||||
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Executor
|
||||||
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
||||||
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
|
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
|
||||||
|
|
||||||
@ -27,10 +27,10 @@ public interface CreateModuleScope {
|
|||||||
* @param initializer Table-related descriptors initializer.
|
* @param initializer Table-related descriptors initializer.
|
||||||
* @return Table descriptor.
|
* @return Table descriptor.
|
||||||
*/
|
*/
|
||||||
public fun <tUE : Any> createTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>, mutable: Boolean = true): Table<tUE, Nothing>
|
public fun <tUE : Any> createTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
* Creates a temporary table that exits only until connection to the database not [closed][Executor._close].
|
||||||
*
|
*
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,7 @@ package ru.landgrafhomyak.db.serdha0.api.module
|
|||||||
|
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
||||||
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Executor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descriptor of synchronized module. Used for schema manipulations.
|
* Descriptor of synchronized module. Used for schema manipulations.
|
||||||
@ -21,13 +21,11 @@ public interface Module<mUE : Any> {
|
|||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("versionKey")
|
@get:JvmName("versionKey")
|
||||||
public val versionKey: String
|
public val versionKey: String
|
||||||
|
/*
|
||||||
/**
|
|
||||||
* Database in which this module was synchronized. For debugging.
|
|
||||||
*/
|
|
||||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||||
@get:JvmName("ownerDatabase")
|
@get:JvmName("ownerDatabase")
|
||||||
public val ownerDatabase: SynchronizedDatabase<*>
|
public val ownerDatabase: Executor
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
public fun <R : Any> createQuery(c: _Query.Constructor<R>): R
|
public fun <R : Any> createQuery(c: _Query.Constructor<R>): R
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package ru.landgrafhomyak.db.serdha0.api.runtime
|
||||||
|
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.module.Module
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.module.ModuleTemplate
|
||||||
|
|
||||||
|
@LowLevelApi
|
||||||
|
public interface DatabaseConnection {
|
||||||
|
@Suppress("FunctionName")
|
||||||
|
@LowLevelApi
|
||||||
|
public fun <UE : Any> _createModuleTemplates(x: ModuleTemplate.VersionsInitializer<UE>): UE
|
||||||
|
|
||||||
|
@Suppress("FunctionName")
|
||||||
|
@LowLevelApi
|
||||||
|
public fun <mUE : Any> _setRootModuleAndLockSchema(t: ModuleTemplate<mUE>): Module<mUE>
|
||||||
|
|
||||||
|
@Suppress("FunctionName")
|
||||||
|
@LowLevelApi
|
||||||
|
public fun _finishSetup()
|
||||||
|
|
||||||
|
@Suppress("PropertyName")
|
||||||
|
@LowLevelApi
|
||||||
|
public val _executor: Executor
|
||||||
|
}
|
@ -6,7 +6,7 @@ import ru.landgrafhomyak.db.serdha0.api.table.RowId
|
|||||||
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
||||||
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
||||||
|
|
||||||
public interface SynchronizedDatabase<DatabaseUserExtension : Any> : Module<DatabaseUserExtension> {
|
public interface Executor {
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
@LowLevelApi
|
@LowLevelApi
|
||||||
public suspend fun _startTransaction(): Transaction
|
public suspend fun _startTransaction(): Transaction
|
||||||
@ -33,10 +33,6 @@ public interface SynchronizedDatabase<DatabaseUserExtension : Any> : Module<Data
|
|||||||
|
|
||||||
public suspend fun <C, A, R> transaction(script: AtomicScript<C, A, R>, context: C, args: A): R
|
public suspend fun <C, A, R> transaction(script: AtomicScript<C, A, R>, context: C, args: A): R
|
||||||
|
|
||||||
@Suppress("FunctionName")
|
|
||||||
@LowLevelApi
|
|
||||||
public suspend fun _close()
|
|
||||||
|
|
||||||
public fun <TableUserException : Any, V> mapOfRowIds(
|
public fun <TableUserException : Any, V> mapOfRowIds(
|
||||||
table: Table<TableUserException, *>,
|
table: Table<TableUserException, *>,
|
||||||
builder: (MutableMap<OutputRow<TableUserException>, V>) -> Unit
|
builder: (MutableMap<OutputRow<TableUserException>, V>) -> Unit
|
@ -1,10 +0,0 @@
|
|||||||
package ru.landgrafhomyak.db.serdha0.api.runtime
|
|
||||||
|
|
||||||
import ru.landgrafhomyak.db.serdha0.api.module.ModuleTemplate
|
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
|
||||||
public interface UnsynchronizedDatabase {
|
|
||||||
public fun <UserExtension : Any> addModuleTemplates(creator: ModuleTemplate.VersionsInitializer<UserExtension>): UserExtension
|
|
||||||
|
|
||||||
public suspend fun <ModuleUserExtension : Any> synchronize(conent: ModuleTemplate<ModuleUserExtension>): SynchronizedDatabase<ModuleUserExtension>
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user