forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
95 additions
and
88 deletions.
There are no files selected for viewing
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
26 changes: 0 additions & 26 deletions
26
...asource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourcesHealthSupport.java
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...runtime/src/main/java/io/quarkus/datasource/runtime/DataSourcesHealthSupportRecorder.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
...s/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourcesRecorder.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,35 @@ | ||
package io.quarkus.datasource.runtime; | ||
|
||
import static java.util.stream.Collectors.toUnmodifiableSet; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Stream; | ||
|
||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class DataSourcesRecorder { | ||
|
||
public RuntimeValue<DataSourcesSupport> configureDataSourcesHealthSupport( | ||
DataSourcesBuildTimeConfig config) { | ||
Stream.Builder<String> configured = Stream.builder(); | ||
Stream.Builder<String> excludedForHealthChecks = Stream.builder(); | ||
for (Map.Entry<String, DataSourceBuildTimeConfig> dataSource : config.dataSources().entrySet()) { | ||
// TODO this is wrong, as the default datasource could be configured without db-kind being set: | ||
// it's inferred automatically for the default datasource when possible. | ||
// We probably fail to register health checks for default datasources | ||
// that don't have db-kind set right now; this needs to be tested and fixed. | ||
if (dataSource.getValue().dbKind().isPresent()) { | ||
configured.add(dataSource.getKey()); | ||
} | ||
if (dataSource.getValue().healthExclude()) { | ||
excludedForHealthChecks.add(dataSource.getKey()); | ||
} | ||
} | ||
Set<String> names = configured.build().collect(toUnmodifiableSet()); | ||
Set<String> excludedNames = excludedForHealthChecks.build().collect(toUnmodifiableSet()); | ||
return new RuntimeValue<>(new DataSourcesSupport(names, excludedNames)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ns/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourcesSupport.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,37 @@ | ||
package io.quarkus.datasource.runtime; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Helper class that holds the names of all configured data sources, | ||
* along with the names of those that are inactive or excluded from health checks. | ||
* <p> | ||
* This is used by any feature that needs runtime access to data sources, | ||
* e.g. Flyway/Liquibase or health check implementation classes. | ||
*/ | ||
public class DataSourcesSupport { | ||
|
||
private final Set<String> configuredNames; | ||
private final Set<String> healthCheckExcludedNames; | ||
private Set<String> inactiveNames; | ||
|
||
public DataSourcesSupport(Set<String> configuredNames, Set<String> healthCheckExcludedNames) { | ||
this.configuredNames = configuredNames; | ||
this.healthCheckExcludedNames = healthCheckExcludedNames; | ||
} | ||
|
||
|
||
// TODO careful when using this, as it might (incorrectly) not include the default datasource. | ||
// See TODO in code that calls the constructor of this class. | ||
public Set<String> getConfiguredNames() { | ||
return configuredNames; | ||
} | ||
|
||
public Set<String> getInactiveNames() { | ||
return inactiveNames; | ||
} | ||
|
||
public Set<String> getHealthCheckExcludedNames() { | ||
return healthCheckExcludedNames; | ||
} | ||
} |
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
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