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

info.jerrinot.flink.connector.questdb.QuestDBConfiguration Maven / Gradle / Ivy

The newest version!
package info.jerrinot.flink.connector.questdb;

import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.factories.FactoryUtil;

import java.io.Serializable;
import java.util.Optional;

public final class QuestDBConfiguration implements Serializable {
    public static final ConfigOption HOST =
            ConfigOptions.key("host")
                    .stringType()
                    .noDefaultValue()
                    .withDescription("QuestDB server hostname and port");

    public static final ConfigOption USERNAME =
            ConfigOptions.key("username")
                    .stringType()
                    .defaultValue("admin")
                    .withDescription("QuestDB server authentication username");

    public static final ConfigOption TOKEN =
            ConfigOptions.key("token")
                    .stringType()
                    .noDefaultValue()
                    .withDescription("QuestDB server authentication token");

    public static final ConfigOption TABLE =
            ConfigOptions.key("table")
                    .stringType()
                    .noDefaultValue()
                    .withDescription("QuestDB target table");

    public static final ConfigOption TLS =
            ConfigOptions.key("tls")
                    .booleanType()
                    .defaultValue(false)
                    .withDescription("Optional enable TLS/SSL encryption");

    public static final ConfigOption BUFFER_SIZE_BYTES =
            ConfigOptions.key("buffer.size.kb")
                    .intType()
                    .noDefaultValue()
                    .withDescription("ILP client buffer size in KB");


    public static final ConfigOption SINK_PARALLELISM = FactoryUtil.SINK_PARALLELISM;

    private final ReadableConfig readableConfig;
    private final String internalCatalogName;


    public QuestDBConfiguration(ReadableConfig readableConfig, String internalCatalogName) {
        this.readableConfig = readableConfig;
        this.internalCatalogName = internalCatalogName;
    }

    public String getTable() {
        return readableConfig.getOptional(TABLE).orElse(internalCatalogName);
    }

    public String getHost() {
        return readableConfig.get(HOST);
    }

    public boolean isTlsEnabled() {
        return readableConfig.get(TLS);
    }

    public String getUserId() {
        return readableConfig.get(USERNAME);
    }

    public Optional getToken() {
        return readableConfig.getOptional(TOKEN);
    }

    public Integer getParallelism() {
        return readableConfig.getOptional(SINK_PARALLELISM).orElse(null);
    }

    public Optional getBufferSize() {
        return readableConfig.getOptional(BUFFER_SIZE_BYTES);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy