use of io.github.cdimascio.dotenv.Dotenv in project soluto-kafka by Soluto.
the class Config method init.
public static void init() throws Exception {
Dotenv dotenv = Dotenv.configure().ignoreIfMissing().load();
KAFKA_BROKER = getString(dotenv, "KAFKA_BROKER");
TOPICS = getStringList(dotenv, "TOPICS");
GROUP_ID = getString(dotenv, "GROUP_ID");
SENDING_PROTOCOL = getString(dotenv, "SENDING_PROTOCOL");
TARGET = getString(dotenv, "TARGET");
POLL_TIMEOUT = getOptionalInt(dotenv, "POLL_TIMEOUT", 1000);
MAX_POLL_RECORDS = getOptionalInt(dotenv, "MAX_POLL_RECORDS", 2);
SESSION_TIMEOUT = getOptionalInt(dotenv, "SESSION_TIMEOUT", 10000);
RETRY_PROCESS_WHEN_STATUS_CODE_MATCH = getOptionalString(dotenv, "RETRY_PROCESS_WHEN_STATUS_CODE_MATCH", "5[0-9][0-9]");
PRODUCE_TO_RETRY_TOPIC_WHEN_STATUS_CODE_MATCH = getOptionalString(dotenv, "PRODUCE_TO_RETRY_TOPIC_WHEN_STATUS_CODE_MATCH", "408");
PRODUCE_TO_DEAD_LETTER_TOPIC_WHEN_STATUS_CODE_MATCH = getOptionalString(dotenv, "PRODUCE_TO_DEAD_LETTER_TOPIC_WHEN_STATUS_CODE_MATCH", "4[0-9][0-79]");
RETRY_POLICY_EXPONENTIAL_BACKOFF = getOptionalIntList(dotenv, "RETRY_POLICY_EXPONENTIAL_BACKOFF", 3, List.of(50, 5000, 10));
RETRY_TOPIC = getOptionalString(dotenv, "RETRY_TOPIC", null);
DEAD_LETTER_TOPIC = getOptionalString(dotenv, "DEAD_LETTER_TOPIC", null);
PROCESSING_DELAY = getOptionalInt(dotenv, "PROCESSING_DELAY", 0);
MONITORING_SERVER_PORT = getOptionalInt(dotenv, "MONITORING_SERVER_PORT", 0);
TARGET_IS_ALIVE_HTTP_ENDPOINT = getOptionalString(dotenv, "TARGET_IS_ALIVE_HTTP_ENDPOINT", null);
BASE64_TRUSTSTORE_FILE_PATH = getOptionalString(dotenv, "BASE64_TRUSTSTORE_FILE_PATH", null);
if (BASE64_TRUSTSTORE_FILE_PATH != null) {
TRUSTSTORE_LOCATION = "client.truststore.jks";
writeToFile(TRUSTSTORE_LOCATION, readFile(getString(dotenv, "BASE64_TRUSTSTORE_FILE_PATH")));
TRUSTSTORE_PASSWORD = readFile(getString(dotenv, "TRUSTSTORE_PASSWORD_FILE_PATH"));
}
SECURITY_PROTOCOL = getOptionalString(dotenv, "SECURITY_PROTOCOL", "");
if (SECURITY_PROTOCOL.equals("SSL")) {
KEYSTORE_LOCATION = "client.keystore.p12";
KEYSTORE_PASSWORD = readFile(getString(dotenv, "KEYSTORE_PASSWORD_FILE_PATH"));
writeToFile(KEYSTORE_LOCATION, readFile(getString(dotenv, "KEYSTORE_FILE_PATH")));
KEY_PASSWORD = readFile(getString(dotenv, "KEY_PASSWORD_FILE_PATH"));
AUTHENTICATED_KAFKA = true;
}
if (SECURITY_PROTOCOL.equals("SASL_SSL")) {
SASL_USERNAME = getString(dotenv, "SASL_USERNAME");
SASL_PASSWORD = readFile(getString(dotenv, "SASL_PASSWORD_FILE_PATH"));
AUTHENTICATED_KAFKA = true;
}
USE_PROMETHEUS = getOptionalBool(dotenv, "USE_PROMETHEUS", false);
PROMETHEUS_BUCKETS = getOptionalString(dotenv, "PROMETHEUS_BUCKETS", "0.003,0.03,0.1,0.3,1.5,10");
LOG_RECORD = getOptionalBool(dotenv, "LOG_RECORD", false);
}
use of io.github.cdimascio.dotenv.Dotenv in project soluto-kafka by Soluto.
the class Config method init.
public static void init() throws Exception {
Dotenv dotenv = Dotenv.configure().ignoreIfMissing().load();
PORT = getInt(dotenv, "PORT");
KAFKA_BROKER = getString(dotenv, "KAFKA_BROKER");
TOPIC = getOptionalString(dotenv, "TOPIC", null);
if (TOPIC != null) {
throw new Error("TOPIC as environment variable is not supported anymore, please pass topic in the producer request");
}
READINESS_TOPIC = getOptionalString(dotenv, "READINESS_TOPIC", null);
LINGER_TIME_MS = getOptionalInt(dotenv, "LINGER_TIME_MS", 0);
COMPRESSION_TYPE = getOptionalString(dotenv, "COMPRESSION_TYPE", "none");
ASYNC = getOptionalBool(dotenv, "ASYNC", true);
String truststoreFilePath = getOptionalString(dotenv, "TRUSTSTORE_FILE_PATH", null);
if (truststoreFilePath != null) {
TRUSTSTORE_LOCATION = "client.truststore.jks";
writeToFile(TRUSTSTORE_LOCATION, readFile(getString(dotenv, "TRUSTSTORE_FILE_PATH")));
TRUSTSTORE_PASSWORD = readFile(getString(dotenv, "TRUSTSTORE_PASSWORD_FILE_PATH"));
}
SECURITY_PROTOCOL = getOptionalString(dotenv, "SECURITY_PROTOCOL", "");
if (SECURITY_PROTOCOL.equals("SSL")) {
KEYSTORE_LOCATION = "client.keystore.p12";
KEYSTORE_PASSWORD = readFile(getString(dotenv, "KEYSTORE_PASSWORD_FILE_PATH"));
writeToFile(KEYSTORE_LOCATION, readFile(getString(dotenv, "KEYSTORE_FILE_PATH")));
KEY_PASSWORD = readFile(getString(dotenv, "KEY_PASSWORD_FILE_PATH"));
AUTHENTICATED_KAFKA = true;
}
if (SECURITY_PROTOCOL.equals("SASL_SSL")) {
SASL_USERNAME = getString(dotenv, "SASL_USERNAME");
SASL_PASSWORD = readFile(getString(dotenv, "SASL_PASSWORD_FILE_PATH"));
AUTHENTICATED_KAFKA = true;
}
USE_PROMETHEUS = getOptionalBool(dotenv, "USE_PROMETHEUS", false);
PROMETHEUS_BUCKETS = getOptionalString(dotenv, PROMETHEUS_BUCKETS, "0.003,0.03,0.1,0.3,1.5,10");
}
Aggregations