public static class ConfigSources.CompositeBuilder extends Object implements Builder<ConfigSource>
ConfigSource that encapsulates multiple separate
ConfigSources.
The caller invokes add(java.util.function.Supplier<io.helidon.config.spi.ConfigSource>) one or more times to assemble an ordered
list of ConfigSources to be combined. The build() and
get() methods return a single ConfigSource that combines
the ordered sequence of ConfigSources using a merging strategy
(by default, the
fallback merging strategy). The caller
can change the merging strategy by passing an alternative strategy to the
mergingStrategy method.
The CompositeBuilder also supports change monitoring. The
application can control these aspects:
| Change Support Behavior | Use | Method |
|---|---|---|
| reload executor | The executor used to reload the configuration upon detection of a change in the
underlying ConfigSource |
changesExecutor(java.util.concurrent.ScheduledExecutorService) |
| debounce timeout | Minimum delay between reloads - helps reduce multiple reloads due to multiple changes in a short period, collecting a group of changes into one notification | changesDebounce(java.time.Duration) |
| buffer size | Maximum number of changes allowed in the change flow | changesMaxBuffer(int) |
| Modifier and Type | Method and Description |
|---|---|
ConfigSources.CompositeBuilder |
add(Supplier<ConfigSource> source)
Adds a
ConfigSource to the ordered list of sources. |
ConfigSource |
build()
Builds new instance of Composite ConfigSource.
|
ConfigSources.CompositeBuilder |
changesDebounce(Duration debounceTimeout)
Specifies debounce timeout for reloading the config after the
underlying config source(s) change.
|
ConfigSources.CompositeBuilder |
changesExecutor(ScheduledExecutorService changesExecutor)
Specifies
ScheduledExecutorService on which reloads of the
config source will occur. |
ConfigSources.CompositeBuilder |
changesMaxBuffer(int changesMaxBuffer)
Specifies maximum capacity for each subscriber's buffer to be used to deliver
config source changes. |
ConfigSource |
get() |
ConfigSources.CompositeBuilder |
mergingStrategy(ConfigSources.MergingStrategy mergingStrategy)
Sets the strategy to be used for merging the root nodes provided by
the list of
ConfigSources. |
public ConfigSources.CompositeBuilder add(Supplier<ConfigSource> source)
ConfigSource to the ordered list of sources.source - config sourcepublic ConfigSources.CompositeBuilder mergingStrategy(ConfigSources.MergingStrategy mergingStrategy)
ConfigSources.mergingStrategy - strategy for merging root nodes from the
config sourcesConfigSources.MergingStrategy.fallback()public ConfigSources.CompositeBuilder changesExecutor(ScheduledExecutorService changesExecutor)
ScheduledExecutorService on which reloads of the
config source will occur.
By default, a dedicated thread pool that can schedule reload commands to
run after a given timeout is used.
changesExecutor - the executor used for scheduling config source
reloadschangesDebounce(Duration)public ConfigSources.CompositeBuilder changesDebounce(Duration debounceTimeout)
Debouncing reduces the number of change events by collecting any changes over the debounce timeout interval into a single event.
The default is 100 milliseconds.
debounceTimeout - debounce timeout to process reloadingchangesExecutor(ScheduledExecutorService)public ConfigSources.CompositeBuilder changesMaxBuffer(int changesMaxBuffer)
config source changes.
By default Flow.defaultBufferSize() is used.
Note: Any events not consumed by a subscriber will be lost.
changesMaxBuffer - the maximum capacity for each subscriber's buffer of Source.changes() events.changesExecutor(ScheduledExecutorService),
Source.changes()public ConfigSource build()
build in interface Builder<ConfigSource>public ConfigSource get()
get in interface Builder<ConfigSource>get in interface Supplier<ConfigSource>Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.