java.util.function.Supplier<ConfigSource>
public static class ConfigSources.CompositeBuilder extends java.lang.Object implements java.util.function.Supplier<ConfigSource>
ConfigSource
that encapsulates multiple separate
ConfigSource
s.
The caller invokes add(java.util.function.Supplier<io.helidon.config.spi.ConfigSource>)
one or more times to assemble an ordered
list of ConfigSource
s to be combined. The build()
and
get()
methods return a single ConfigSource
that combines
the ordered sequence of ConfigSource
s 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 | Description |
---|---|---|
ConfigSources.CompositeBuilder |
add(java.util.function.Supplier<ConfigSource> source) |
Adds a
ConfigSource to the ordered list of sources. |
ConfigSource |
build() |
Builds new instance of Composite ConfigSource.
|
ConfigSources.CompositeBuilder |
changesDebounce(java.time.Duration debounceTimeout) |
Specifies debounce timeout for reloading the config after the
underlying config source(s) change.
|
ConfigSources.CompositeBuilder |
changesExecutor(java.util.concurrent.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
ConfigSource s. |
public ConfigSources.CompositeBuilder add(java.util.function.Supplier<ConfigSource> source)
ConfigSource
to the ordered list of sources.source
- config sourcepublic ConfigSources.CompositeBuilder mergingStrategy(ConfigSources.MergingStrategy mergingStrategy)
ConfigSource
s.mergingStrategy
- strategy for merging root nodes from the
config sourcesConfigSources.MergingStrategy.fallback()
public ConfigSources.CompositeBuilder changesExecutor(java.util.concurrent.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(java.time.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.DEFAULT_BUFFER_SIZE
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()
public ConfigSource get()
get
in interface java.util.function.Supplier<ConfigSource>
Copyright © 2018 Oracle Corporation. All rights reserved.