io.quarkus.datasource.runtime.DataSourceRecorder Maven / Gradle / Ivy
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 DataSourceRecorder {
public RuntimeValue createDataSourceSupport(
DataSourcesBuildTimeConfig buildTimeConfig,
DataSourcesRuntimeConfig runtimeConfig) {
Stream.Builder excludedForHealthChecks = Stream.builder();
for (Map.Entry dataSource : buildTimeConfig.dataSources().entrySet()) {
if (dataSource.getValue().healthExclude()) {
excludedForHealthChecks.add(dataSource.getKey());
}
}
Set excludedNames = excludedForHealthChecks.build().collect(toUnmodifiableSet());
Stream.Builder inactive = Stream.builder();
for (Map.Entry entry : runtimeConfig.dataSources().entrySet()) {
if (!entry.getValue().active()) {
inactive.add(entry.getKey());
}
}
Set inactiveNames = inactive.build().collect(toUnmodifiableSet());
return new RuntimeValue<>(new DataSourceSupport(excludedNames, inactiveNames));
}
}