...
Code Block | ||
---|---|---|
| ||
public interface ConfigProvider extends Configurable, Closeable { // Configure this class with the initialization parameters void configure(Map<String, ?> configs); // Look up the data at the given path. ConfigData get(String path); // Look up the data with the given keys at the given path. ConfigData get(String path, Set<String> keys); // The ConfigProvider is responsible for making this callback whenever the key changes. // Some ConfigProviders may want to have a background thread with a configurable update interval. void subscribe(String path, Set<String> keys, ConfigChangeCallback callback); // Inverse of subscribe void unsubscribe(String path, Set<String> key); // Close all subscriptions and clean up all resources void close(); } public class ConfigData { private long ttl; private Map<String, String> data; public ConfigData(long ttl, Map<String, String> data, long ttl) { this.ttl = ttl; this.data = data; } public ConfigData(Map<String, String> data) { this(Long.MAX_VALUE, data); } public long ttl() { return ttl; } public Map<String, String> data() { return data; } } public interface ConfigChangeCallback { void onChange(String path, Map<String, String> values); } |
...