Class SystemEnvPropertyOverrides
- java.lang.Object
-
- org.creekservice.api.kafka.extension.config.SystemEnvPropertyOverrides
-
- All Implemented Interfaces:
KafkaPropertyOverrides
public final class SystemEnvPropertyOverrides extends java.lang.Object implements KafkaPropertyOverrides
Loads Kafka client property overrides from environment variables.Variables can either target a specific cluster name or be common across all clusters.
Common variables, not targeted at a specific cluster, or where the service only accesses a single cluster (which is the most common pattern), should have variable names in the format:
KAFKA_<PROPERTY_NAME>
where:- PROPERTY_NAME is Kafka client property name, in uppercase, with periods
.
replaced with underscores_
For example, config
boostrap.servers
can be set with a variable name ofKAFKA_BOOTSTRAP_SERVERS
.In the unusual situation that a service access multiple Kafka clusters, a variable can target at a specific Kafka cluster. Such variables should have a name in the format:
KAFKA_<CLUSTER_NAME>_<PROPERTY_NAME>
where:- CLUSTER_NAME is the specific name of the Kafka cluster, as returned by
KafkaTopicDescriptor.cluster()
), in uppercase and any dashes-
replaced with underscores_
. - PROPERTY_NAME is Kafka client property name, in uppercase, with periods
.
replaced with underscores_
For example, config
boostrap.servers
for themain-cluster
cluster can be set with a variable name ofKAFKA_MAIN_CLUSTER_BOOTSTRAP_SERVERS
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.util.Map<java.lang.String,?>
get(java.lang.String clusterName)
Get Kafka client property overrides for a cluster.int
hashCode()
void
init(java.util.Set<java.lang.String> clusterNames)
Initialize the overrides providerstatic KafkaPropertyOverrides
systemEnvPropertyOverrides()
Factory method
-
-
-
Method Detail
-
systemEnvPropertyOverrides
public static KafkaPropertyOverrides systemEnvPropertyOverrides()
Factory method- Returns:
- kafka overrides.
-
init
public void init(java.util.Set<java.lang.String> clusterNames)
Description copied from interface:KafkaPropertyOverrides
Initialize the overrides provider- Specified by:
init
in interfaceKafkaPropertyOverrides
- Parameters:
clusterNames
- the set of known Kafka cluster names.
-
get
public java.util.Map<java.lang.String,?> get(java.lang.String clusterName)
Description copied from interface:KafkaPropertyOverrides
Get Kafka client property overrides for a cluster.- Specified by:
get
in interfaceKafkaPropertyOverrides
- Parameters:
clusterName
- the name of the cluster to get the overrides for.- Returns:
- property overrides.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-