-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable autocommit at the db connection level and activate the requir…
…ed datasource programatically
- Loading branch information
1 parent
02ecd4c
commit 5fc4a6c
Showing
8 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
app/src/main/java/io/apicurio/registry/services/DatabaseConfigInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.apicurio.registry.services; | ||
|
||
import io.apicurio.registry.storage.impl.sql.RegistryDatabaseKind; | ||
import io.smallrye.config.ConfigSourceInterceptor; | ||
import io.smallrye.config.ConfigSourceInterceptorContext; | ||
import io.smallrye.config.ConfigValue; | ||
import jakarta.annotation.Priority; | ||
|
||
@Priority(100) | ||
public class DatabaseConfigInterceptor implements ConfigSourceInterceptor { | ||
|
||
@Override | ||
public ConfigValue getValue(ConfigSourceInterceptorContext context, String name) { | ||
ConfigValue storageKind = context.proceed("apicurio.storage.sql.kind"); | ||
RegistryDatabaseKind databaseKind = RegistryDatabaseKind.valueOf(storageKind.getValue()); | ||
|
||
switch (name) { | ||
case "quarkus.datasource.postgresql.active" -> { | ||
if (databaseKind.equals(RegistryDatabaseKind.postgresql)) { | ||
return ConfigValue.builder().withName(name).withValue("true").build(); | ||
} else { | ||
return ConfigValue.builder().withName(name).withValue("false").build(); | ||
} | ||
} | ||
case "quarkus.datasource.mssql.active" -> { | ||
if (databaseKind.equals(RegistryDatabaseKind.mssql)) { | ||
return ConfigValue.builder().withName(name).withValue("true").build(); | ||
} else { | ||
return ConfigValue.builder().withName(name).withValue("false").build(); | ||
} | ||
} | ||
case "quarkus.datasource.mysql.active" -> { | ||
if (databaseKind.equals(RegistryDatabaseKind.mysql)) { | ||
return ConfigValue.builder().withName(name).withValue("true").build(); | ||
} else { | ||
return ConfigValue.builder().withName(name).withValue("false").build(); | ||
} | ||
} | ||
case "quarkus.datasource.h2.active" -> { | ||
if (databaseKind.equals(RegistryDatabaseKind.h2)) { | ||
return ConfigValue.builder().withName(name).withValue("true").build(); | ||
} else { | ||
return ConfigValue.builder().withName(name).withValue("false").build(); | ||
} | ||
} | ||
} | ||
|
||
return context.proceed(name); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.apicurio.registry.services.DatabaseConfigInterceptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
utils/exportConfluent/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
quarkus.package.main-class=ConfluentExport | ||
|
||
quarkus.log.level=WARN | ||
quarkus.package.type=uber-jar | ||
quarkus.package.jar.type=legacy-jar |