- java.lang.Object
-
- io.helidon.config.AbstractSource
-
- io.helidon.config.AbstractConfigSource
-
- io.helidon.config.etcd.EtcdConfigSource
-
- All Implemented Interfaces:
ConfigSource
,ParsableSource
,PollableSource<Long>
,Source
,WatchableSource<EtcdConfigSourceBuilder.EtcdEndpoint>
,Supplier<ConfigSource>
public class EtcdConfigSource extends AbstractConfigSource implements PollableSource<Long>, WatchableSource<EtcdConfigSourceBuilder.EtcdEndpoint>, ParsableSource
A config source which loads a configuration document from Etcd.Config source is initialized by
EtcdConfigSourceBuilder
.- See Also:
EtcdConfigSourceBuilder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.ParsableSource
ParsableSource.Builder<B extends ParsableSource.Builder<B>>
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.PollableSource
PollableSource.Builder<T extends PollableSource.Builder<T>>
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.Source
Source.Builder<B extends Source.Builder<B>>
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.WatchableSource
WatchableSource.Builder<B extends WatchableSource.Builder<B,T>,T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EtcdConfigSourceBuilder
builder()
Create a new fluent API builder for etcd.Optional<ChangeWatcher<Object>>
changeWatcher()
A change watcher of this source, if it implementsWatchableSource
and has one configured.static EtcdConfigSource
create(Config metaConfig)
Create a new instance from configuration.static EtcdConfigSource
create(URI uri, String key, EtcdConfigSourceBuilder.EtcdApi api)
Create a configured instance with the provided options.boolean
isModified(Long stamp)
This method is invoked to check if this source has changed.Optional<ConfigParser.Content>
load()
Loads the underlying source data.Optional<String>
mediaType()
Media type if on eis configured for parsing content ofParsableSource
.Optional<ConfigParser>
parser()
Config parser if one is configured to use for parsing content ofParsableSource
.Optional<PollingStrategy>
pollingStrategy()
A polling strategy of this source, if it implementsPollableSource
and has one configured.EtcdConfigSourceBuilder.EtcdEndpoint
target()
The target of this source.Class<EtcdConfigSourceBuilder.EtcdEndpoint>
targetType()
Target type as supported by this source.protected String
uid()
Returns universal id of source to be used to constructAbstractSource.description()
.-
Methods inherited from class io.helidon.config.AbstractConfigSource
toString
-
Methods inherited from class io.helidon.config.AbstractSource
description, optional, retryPolicy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.helidon.config.spi.ConfigSource
get, init
-
Methods inherited from interface io.helidon.config.spi.ParsableSource
relativeResolver
-
Methods inherited from interface io.helidon.config.spi.Source
description, exists, optional, retryPolicy
-
-
-
-
Method Detail
-
uid
protected String uid()
Description copied from class:AbstractSource
Returns universal id of source to be used to constructAbstractSource.description()
.- Overrides:
uid
in classAbstractSource
- Returns:
- universal id of source
-
parser
public Optional<ConfigParser> parser()
Description copied from class:AbstractConfigSource
Config parser if one is configured to use for parsing content ofParsableSource
. If one is not configured on a source (default), a parser is chosen based onAbstractConfigSource.mediaType()
.- Specified by:
parser
in interfaceParsableSource
- Overrides:
parser
in classAbstractConfigSource
- Returns:
- a configured parser, or empty if one should be chosen from media type (or if this is not a parsable source)
-
mediaType
public Optional<String> mediaType()
Description copied from class:AbstractConfigSource
Media type if on eis configured for parsing content ofParsableSource
. If there is none configured (default), a parser is chosen based onConfigParser.Content.mediaType()
- media type detected during load of data.- Specified by:
mediaType
in interfaceParsableSource
- Overrides:
mediaType
in classAbstractConfigSource
- Returns:
- configured media type or empty if none configured
-
pollingStrategy
public Optional<PollingStrategy> pollingStrategy()
Description copied from class:AbstractSource
A polling strategy of this source, if it implementsPollableSource
and has one configured.- Specified by:
pollingStrategy
in interfacePollableSource<Long>
- Overrides:
pollingStrategy
in classAbstractSource
- Returns:
- polling strategy if any configured
-
changeWatcher
public Optional<ChangeWatcher<Object>> changeWatcher()
Description copied from class:AbstractSource
A change watcher of this source, if it implementsWatchableSource
and has one configured.- Specified by:
changeWatcher
in interfaceWatchableSource<EtcdConfigSourceBuilder.EtcdEndpoint>
- Overrides:
changeWatcher
in classAbstractSource
- Returns:
- change watcher if any configured
-
target
public EtcdConfigSourceBuilder.EtcdEndpoint target()
Description copied from interface:WatchableSource
The target of this source.- Specified by:
target
in interfaceWatchableSource<EtcdConfigSourceBuilder.EtcdEndpoint>
- Returns:
- target this source is configured with, never
null
-
targetType
public Class<EtcdConfigSourceBuilder.EtcdEndpoint> targetType()
Description copied from interface:WatchableSource
Target type as supported by this source.- Specified by:
targetType
in interfaceWatchableSource<EtcdConfigSourceBuilder.EtcdEndpoint>
- Returns:
- class of the target, by default used for
WatchableSource.target()
-
isModified
public boolean isModified(Long stamp)
Description copied from interface:PollableSource
This method is invoked to check if this source has changed.- Specified by:
isModified
in interfacePollableSource<Long>
- Parameters:
stamp
- the stamp of the last loaded content- Returns:
true
if the current data of this config source differ from the loaded data, including cases when the source has disappeared
-
load
public Optional<ConfigParser.Content> load() throws ConfigException
Description copied from interface:ParsableSource
Loads the underlying source data. This method is only called when the sourceSource.exists()
.The method can be invoked repeatedly, for example during retries. In case the underlying data is gone or does not exist, return an empty optional.
- Specified by:
load
in interfaceParsableSource
- Returns:
- An instance of
T
as read from the underlying origin of the data (if it exists) - Throws:
ConfigException
- in case of errors loading from the underlying origin
-
create
public static EtcdConfigSource create(URI uri, String key, EtcdConfigSourceBuilder.EtcdApi api)
Create a configured instance with the provided options.- Parameters:
uri
- Remote etcd URIkey
- key the configuration is associated withapi
- api version- Returns:
- a new etcd config source
-
create
public static EtcdConfigSource create(Config metaConfig)
Create a new instance from configuration.- Parameters:
metaConfig
- meta configuration to load config source from- Returns:
- configured source instance
-
builder
public static EtcdConfigSourceBuilder builder()
Create a new fluent API builder for etcd.- Returns:
- a new builder
-
-