DataSourceBuilder is a builder for configuring the file-based data source.
Obtain an instance of this type by calling DataSource. After calling its methods to specify any desired custom settings, store it in the DataSource field of github.com/launchdarkly/go-server-sdk/v6.Config.
Builder calls can be chained, for example:
config.DataStore = ldfiledata.DataSource().FilePaths("file1").FilePaths("file2")
You do not need to call the builder's Build method yourself; that will be done by the SDK.
type DataSourceBuilder struct {
// contains filtered or unexported fields
}
func DataSource() *DataSourceBuilder
DataSource returns a configurable builder for a file-based data source.
func (b *DataSourceBuilder) Build(context subsystems.ClientContext) (subsystems.DataSource, error)
Build is called internally by the SDK.
func (b *DataSourceBuilder) DuplicateKeysHandling(duplicateKeysHandling DuplicateKeysHandling) *DataSourceBuilder
DuplicateKeysHandling specifies how to handle keys that are duplicated across files.
If this is not specified, or if you set it to an unrecognized value, the default is DuplicateKeysFail.
func (b *DataSourceBuilder) FilePaths(paths ...string) *DataSourceBuilder
FilePaths specifies the input data files. The paths may be any number of absolute or relative file paths.
func (b *DataSourceBuilder) Reloader(reloaderFactory ReloaderFactory) *DataSourceBuilder
Reloader specifies a mechanism for reloading data files.
It is normally used with the github.com/launchdarkly/go-server-sdk/v6/ldfilewatch package, as follows:
config := ld.Config{ DataSource: ldfiledata.DataSource(). FilePaths(filePaths). Reloader(ldfilewatch.WatchFiles), }
DuplicateKeysHandling is a parameter type used with DataSourceBuilder.DuplicateKeysHandling.
type DuplicateKeysHandling string
const ( // DuplicateKeysFail is an option for DataSourceBuilder.DuplicateKeysHandling, meaning that data loading // should fail if keys are duplicated across files. This is the default behavior. DuplicateKeysFail DuplicateKeysHandling = "fail" // DuplicateKeysIgnoreAllButFirst is an option for DataSourceBuilder.DuplicateKeysHandling, meaning that // if keys are duplicated across files the first occurrence will be used. DuplicateKeysIgnoreAllButFirst DuplicateKeysHandling = "ignore" )
ReloaderFactory is a function type used with DataSourceBuilder.Reloader, to specify a mechanism for detecting when data files should be reloaded. Its standard implementation is in the ldfilewatch package.
type ReloaderFactory func(paths []string, loggers ldlog.Loggers, reload func(), closeCh <-chan struct{}) error