Interface FileOverrideSourceOptionsExperimental

Configuration of the file-based override source.

The source reads flag and segment overrides from one or more local files and reloads them as the files change. The files use the same document format as the file data source: a JSON or YAML document with optional flags, flagValues, and segments members. flagValues entries expand into full flag definitions that return the given value for every context.

A configured file that does not exist contributes no overrides. It can be created later, and deleting it removes its overrides. A file that exists but cannot be read or parsed fails that reload: the previously loaded overrides stay in effect, the failure is logged, and the source retries. Every applied change is logged at Info level with the overrides in effect and what each file supplied.

Example

const client = init(sdkKey, {
dataSystem: {
overrides: { type: 'file', paths: ['/etc/launchdarkly/overrides.json'] },
},
});

Flag overrides are currently experimental and subject to change.

Hierarchy

  • FileOverrideSourceOptions

Properties

changeDetection?: "polling" | "watching"

How the source detects file changes. The two modes are alternatives.

polling, the default, examines the files on a fixed interval and reloads when the modification time or the size of a file changes. It works on every filesystem, including network mounts and directories whose contents are swapped through symbolic links.

watching reloads in response to filesystem change notifications for the directories that contain the files. It reacts faster than polling. It depends on notifications, which some filesystems do not deliver reliably.

duplicateKeysHandling?: "fail" | "ignore"

What to do when the same flag or segment key appears in more than one file. fail, the default, treats the reload as failed and keeps the previously loaded overrides. ignore keeps the entry from the first configured file that defines the key and discards the others.

paths: string[]

The paths of the files to read, in precedence order. At least one path is required. The order decides which file wins under the duplicate keys handling when the same key appears in more than one file.

pollInterval?: number

The interval between examinations of the files in polling mode, in seconds. The default is

  1. An interval below 1 is raised to 1. A value that is not a finite number, or that exceeds 2147483 seconds, is invalid and the default is used. Watching mode ignores it.
type: "file"
yamlParser?: ((data) => any)

Type declaration

    • (data): any
    • A YAML parser for YAML files. The SDK does not include one; to read YAML files, supply a parser that produces the same structure as JSON.parse, for example the parse function of the yaml package. A YAML file configured without a parser fails client construction.

      Parameters

      • data: string

      Returns any

Generated using TypeDoc