Class SystemEnvPropertyOverrides

java.lang.Object
org.creekservice.api.kafka.extension.config.SystemEnvPropertyOverrides
All Implemented Interfaces:
KafkaPropertyOverrides

public final class SystemEnvPropertyOverrides extends 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 of KAFKA_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 the main-cluster cluster can be set with a variable name of KAFKA_MAIN_CLUSTER_BOOTSTRAP_SERVERS.

  • Method Details

    • systemEnvPropertyOverrides

      public static KafkaPropertyOverrides systemEnvPropertyOverrides()
      Factory method
      Returns:
      kafka overrides.
    • init

      public void init(Set<String> clusterNames)
      Description copied from interface: KafkaPropertyOverrides
      Initialize the overrides provider
      Specified by:
      init in interface KafkaPropertyOverrides
      Parameters:
      clusterNames - the set of known Kafka cluster names.
    • get

      public Map<String,​?> get(String clusterName)
      Description copied from interface: KafkaPropertyOverrides
      Get Kafka client property overrides for a cluster.
      Specified by:
      get in interface KafkaPropertyOverrides
      Parameters:
      clusterName - the name of the cluster to get the overrides for.
      Returns:
      property overrides.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object