public final class FileDataSourceBuilder extends java.lang.Object implements UpdateProcessorFactory
FileData.dataSource()
,
call the builder method filePaths(String...)
to specify file path(s),
then pass the resulting object to LDConfig.Builder.dataSource(UpdateProcessorFactory)
.
For more details, see FileData
.
Constructor and Description |
---|
FileDataSourceBuilder() |
Modifier and Type | Method and Description |
---|---|
FileDataSourceBuilder |
autoUpdate(boolean autoUpdate)
Specifies whether the data source should watch for changes to the source file(s) and reload flags
whenever there is a change.
|
UpdateProcessor |
createUpdateProcessor(java.lang.String sdkKey,
LDConfig config,
FeatureStore featureStore)
Used internally by the LaunchDarkly client.
|
FileDataSourceBuilder |
filePaths(java.nio.file.Path... filePaths)
Adds any number of source files for loading flag data, specifying each file path as a Path.
|
FileDataSourceBuilder |
filePaths(java.lang.String... filePaths)
Adds any number of source files for loading flag data, specifying each file path as a string.
|
public FileDataSourceBuilder filePaths(java.lang.String... filePaths) throws java.nio.file.InvalidPathException
Files will be parsed as JSON if their first non-whitespace character is '{'. Otherwise, they will be parsed as YAML.
filePaths
- path(s) to the source file(s); may be absolute or relative to the current working directoryjava.nio.file.InvalidPathException
- if one of the parameters is not a valid file pathpublic FileDataSourceBuilder filePaths(java.nio.file.Path... filePaths)
Files will be parsed as JSON if their first non-whitespace character is '{'. Otherwise, they will be parsed as YAML.
filePaths
- path(s) to the source file(s); may be absolute or relative to the current working directorypublic FileDataSourceBuilder autoUpdate(boolean autoUpdate)
Note that auto-updating will only work if all of the files you specified have valid directory paths at startup time; if a directory does not exist, creating it later will not result in files being loaded from it.
autoUpdate
- true if flags should be reloaded whenever a source file changespublic UpdateProcessor createUpdateProcessor(java.lang.String sdkKey, LDConfig config, FeatureStore featureStore)
createUpdateProcessor
in interface UpdateProcessorFactory
sdkKey
- the SDK key for your LaunchDarkly environmentconfig
- the LaunchDarkly configurationfeatureStore
- the FeatureStore
to use for storing the latest flag stateUpdateProcessor