chore(tests+config): enhance EntriesIsolationIntegrationTest and add missing Spring metadata
- Improved schema isolation logic with constants for tenant schemas and search path management in PostgreSQL. - Added `withTenant` utility in `TenantContextHolder` to simplify tenant context usage. - Removed unused imports, variables, and helper functions (`random()` and redundant `NennungRepository` references). - Included missing `multitenancy.*` configuration keys in `additional-spring-configuration-metadata.json` to address IDE warnings.
This commit is contained in:
+11
-1
@@ -3,7 +3,17 @@ package at.mocode.entries.service.tenant
|
||||
object TenantContextHolder {
|
||||
private val tl = ThreadLocal<Tenant?>()
|
||||
|
||||
fun set(tenant: Tenant) { tl.set(tenant) }
|
||||
fun set(tenant: Tenant?) { tl.set(tenant) }
|
||||
fun clear() { tl.remove() }
|
||||
fun current(): Tenant? = tl.get()
|
||||
|
||||
inline fun <T> withTenant(tenant: Tenant, block: () -> T): T {
|
||||
val old = current()
|
||||
set(tenant)
|
||||
try {
|
||||
return block()
|
||||
} finally {
|
||||
set(old)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "multitenancy.registry.type",
|
||||
"type": "java.lang.String",
|
||||
"description": "Type of tenant registry (jdbc or inmem).",
|
||||
"defaultValue": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "multitenancy.defaultSchemas",
|
||||
"type": "java.lang.String",
|
||||
"description": "Comma-separated list of default schemas for inmem registry.",
|
||||
"defaultValue": "public"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user