Documentation
¶
Overview ¶
Package filedata contains the file reading, parsing, and merging logic shared by the components that load flag and segment data from local files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsFilePaths ¶
AbsFilePaths converts each of the given paths to an absolute path.
func MakeFlagWithValue ¶
func MakeFlagWithValue(key string, v interface{}) *ldmodel.FeatureFlag
MakeFlagWithValue expands a flag-key-to-value entry into a full flag definition that returns the given value for every context.
Types ¶
type Document ¶
type Document struct {
Flags *map[string]ldmodel.FeatureFlag
FlagValues *map[string]ldvalue.Value
Segments *map[string]ldmodel.Segment
}
Document is the parsed form of a single data file. A document may contain full flag definitions, simplified flag-key-to-value entries, and segment definitions.
type DuplicateKeysHandling ¶
type DuplicateKeysHandling string
DuplicateKeysHandling determines what happens when the same flag or segment key appears in more than one document.
The values match the public option types in the packages that expose this behavior, so those types can be converted to this one directly.
const ( // DuplicateKeysFail means a duplicated key causes the merge to fail. DuplicateKeysFail DuplicateKeysHandling = "fail" // DuplicateKeysIgnoreAllButFirst means only the first occurrence of a duplicated key is // used, in the order the documents were given. DuplicateKeysIgnoreAllButFirst DuplicateKeysHandling = "ignore" )
type MergeResult ¶
type MergeResult struct {
Flags []ldstoretypes.KeyedItemDescriptor
Segments []ldstoretypes.KeyedItemDescriptor
}
MergeResult holds the merged items from one or more documents. Item values are *ldmodel.FeatureFlag or *ldmodel.Segment.
Ordering is deterministic at document granularity only: all of one document's items precede the next document's, matching the order the documents were given, but the relative order of items within a single document is unspecified. Consumers key items by their Key and must not rely on within-document ordering.
func Merge ¶
func Merge(duplicateKeysHandling DuplicateKeysHandling, docs ...Document) (MergeResult, error)
Merge combines the items of the given documents, expanding flag-value entries into full flag definitions and applying the given duplicate-key handling. An unrecognized DuplicateKeysHandling value behaves as DuplicateKeysFail.