Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • ConfigProviderConfigData, and ConfigContext:  These interfaces are used to abstract a provider of configuration properties.
  • ConfigTransformer:  This class is used to provide variable substitution for a configuration value, by looking up variables (or indirect references) from a set of ConfigProvider instances.  It only provides one level of indirection.

Code Block
languagejava
public interface ConfigProvider extends Configurable, Closeable {
     
    // Configure this class with the initialization parameters
    void configure(Map<String, ?> configs);
 
    // Lookup up the data at the given path.
    ConfigData lookup(ConfigContext ctx, String path);

    // Lookup up the data with the given keys at the given path.
    ConfigData lookup(ConfigContext ctx, String path, Set<String> keys);
}
 
public interface ConfigContext {
 
    // The name of the client
    String name();
 
    // Schedule a reload, possibly for secrets rotation
    void scheduleConfigReload(long delayMs);
}
 
public class ConfigData {

    private Map<String, String> metadata;
    private Map<String, String> data;

    public ConfigData(Map<String, String> metadata, Map<String, String> data) {
        this.metadata = metadata;
        this.data = data;
    }

    public Map<String, String> metadata() {
        return metadata;
    }

    public Map<String, String> data() {
        return data;
    }
}

...