Class ConfigSources.CompositeBuilder
- java.lang.Object
-
- io.helidon.config.ConfigSources.CompositeBuilder
-
- All Implemented Interfaces:
Builder<ConfigSource>,Supplier<ConfigSource>
- Enclosing class:
- ConfigSources
public static class ConfigSources.CompositeBuilder extends Object implements Builder<ConfigSource>
Builder of aConfigSourcethat encapsulates multiple separateConfigSources.The caller invokes
add(java.util.function.Supplier<io.helidon.config.spi.ConfigSource>)one or more times to assemble an ordered list ofConfigSources to be combined. Thebuild()andget()methods return a singleConfigSourcethat combines the ordered sequence ofConfigSources using a merging strategy (by default, thefallback merging strategy). The caller can change the merging strategy by passing an alternative strategy to themergingStrategymethod.The
CompositeBuilderalso supports change monitoring. The application can control these aspects:Application Control of Change Monitoring Change Support Behavior Use Method reload executor The executor used to reload the configuration upon detection of a change in the underlying ConfigSourcechangesExecutor(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)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigSources.CompositeBuilderadd(Supplier<ConfigSource> source)Adds aConfigSourceto the ordered list of sources.ConfigSourcebuild()Builds new instance of Composite ConfigSource.ConfigSources.CompositeBuilderchangesDebounce(Duration debounceTimeout)Specifies debounce timeout for reloading the config after the underlying config source(s) change.ConfigSources.CompositeBuilderchangesExecutor(ScheduledExecutorService changesExecutor)SpecifiesScheduledExecutorServiceon which reloads of the config source will occur.ConfigSources.CompositeBuilderchangesMaxBuffer(int changesMaxBuffer)Specifies maximum capacity for each subscriber's buffer to be used to deliverconfig source changes.ConfigSourceget()ConfigSources.CompositeBuildermergingStrategy(ConfigSources.MergingStrategy mergingStrategy)Sets the strategy to be used for merging the root nodes provided by the list ofConfigSources.
-
-
-
Method Detail
-
add
public ConfigSources.CompositeBuilder add(Supplier<ConfigSource> source)
Adds aConfigSourceto the ordered list of sources.- Parameters:
source- config source- Returns:
- updated builder
-
mergingStrategy
public ConfigSources.CompositeBuilder mergingStrategy(ConfigSources.MergingStrategy mergingStrategy)
Sets the strategy to be used for merging the root nodes provided by the list ofConfigSources.- Parameters:
mergingStrategy- strategy for merging root nodes from the config sources- Returns:
- updated builder
- See Also:
ConfigSources.MergingStrategy.fallback()
-
changesExecutor
public ConfigSources.CompositeBuilder changesExecutor(ScheduledExecutorService changesExecutor)
SpecifiesScheduledExecutorServiceon which reloads of the config source will occur.By default, a dedicated thread pool that can schedule reload commands to run after a given
timeoutis used.- Parameters:
changesExecutor- the executor used for scheduling config source reloads- Returns:
- updated builder
- See Also:
changesDebounce(Duration)
-
changesDebounce
public ConfigSources.CompositeBuilder changesDebounce(Duration debounceTimeout)
Specifies debounce timeout for reloading the config after the underlying config source(s) change.Debouncing reduces the number of change events by collecting any changes over the debounce timeout interval into a single event.
The default is
100milliseconds.- Parameters:
debounceTimeout- debounce timeout to process reloading- Returns:
- modified builder instance
- See Also:
changesExecutor(ScheduledExecutorService)
-
changesMaxBuffer
public ConfigSources.CompositeBuilder changesMaxBuffer(int changesMaxBuffer)
Specifies maximum capacity for each subscriber's buffer to be used to deliverconfig source changes.By default
Flow.defaultBufferSize()is used.Note: Any events not consumed by a subscriber will be lost.
- Parameters:
changesMaxBuffer- the maximum capacity for each subscriber's buffer ofSource.changes()events.- Returns:
- modified builder instance
- See Also:
changesExecutor(ScheduledExecutorService),Source.changes()
-
build
public ConfigSource build()
Builds new instance of Composite ConfigSource.- Specified by:
buildin interfaceBuilder<ConfigSource>- Returns:
- new instance of Composite ConfigSource.
-
get
public ConfigSource get()
- Specified by:
getin interfaceBuilder<ConfigSource>- Specified by:
getin interfaceSupplier<ConfigSource>
-
-