All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.datasource.runtime.DataSourceRecorder Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy