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 aConfigSource
that encapsulates multiple separateConfigSource
s.The caller invokes
add(java.util.function.Supplier<io.helidon.config.spi.ConfigSource>)
one or more times to assemble an ordered list ofConfigSource
s to be combined. Thebuild()
andget()
methods return a singleConfigSource
that combines the ordered sequence ofConfigSource
s using a merging strategy (by default, thefallback merging strategy
). The caller can change the merging strategy by passing an alternative strategy to themergingStrategy
method.The
CompositeBuilder
also 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 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)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigSources.CompositeBuilder
add(Supplier<ConfigSource> source)
Adds aConfigSource
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)
SpecifiesScheduledExecutorService
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 deliverconfig 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 ofConfigSource
s.
-
-
-
Method Detail
-
add
public ConfigSources.CompositeBuilder add(Supplier<ConfigSource> source)
Adds aConfigSource
to 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 ofConfigSource
s.- 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)
SpecifiesScheduledExecutorService
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.- 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
100
milliseconds.- 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:
build
in interfaceBuilder<ConfigSource>
- Returns:
- new instance of Composite ConfigSource.
-
get
public ConfigSource get()
- Specified by:
get
in interfaceBuilder<ConfigSource>
- Specified by:
get
in interfaceSupplier<ConfigSource>
-
-