Documentation ¶
Index ¶
- func AlwaysFalse(_ string, _ reflect.Type) bool
- func AlwaysTrue(_ string, _ reflect.Type) bool
- func FromCompositeObject(object interface{}, current string, namespace *[]string, options ...OptionFunc) error
- func FromComposition(object interface{}, current string, namespace *[]string) error
- func FromCompositionTags(object interface{}, current string, namespace *[]string) error
- func FromJSON(data *[]byte, current string, namespace *[]string) error
- func FromMap(m map[string]interface{}, current string, namespace *[]string) error
- func GetStructValueByNamespace(object interface{}, ns []string) interface{}
- func GetValueByNamespace(object interface{}, ns []string) interface{}
- func ReplaceNotAllowedCharsInNamespacePart(ns string) string
- func ValidateMetricNamespacePart(ns string) error
- type FlagFunc
- type OptionFunc
- func EntryForContainersRoot(flagFunc FlagFunc) OptionFunc
- func ExportJsonFieldNames(flagFunc FlagFunc) OptionFunc
- func InspectEmptyContainers(flagFunc FlagFunc) OptionFunc
- func InspectNilPointers(flagFunc FlagFunc) OptionFunc
- func SanitizeNamespaceParts(flagFunc FlagFunc) OptionFunc
- func WildcardEntryInContainer(flagFunc FlagFunc) OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromCompositeObject ¶
func FromCompositeObject(object interface{}, current string, namespace *[]string, options ...OptionFunc) error
CompositeObjectToNs inspects an object to construct a list of paths to data.
Operation of this method is controlled by options, which default to:
InspectEmptyContainers(AlwaysTrue), InspectNilPointers(AlwaysTrue), EntryForContainersRoot(AlwaysFalse), ExportJsonFieldNames(AlwaysTrue), WildcardEntryInContainer(AlwaysFalse), SanitizeNamespaceParts(AlwaysTrue).
Different options may be specified to implement selective and context-sensitive inspection.
func FromComposition ¶
FromComposition constructs list of namespaces from multilevel struct compositions using field names as namespace entries. 'Current' value is prefixed to all namespace elements. It returns nil in case of success or error if building namespaces failed.
func FromCompositionTags ¶
FromCompositionTags constructs list of namespaces from multilevel struct composition using field tags as namespace entries. 'Current' value is prefixed to all namespace elements. It returns nil in case of success or error if building namespaces failed.
func FromJSON ¶
FromJSON constructs list of namespaces from json document using json literals as namespace entries. 'Current' value is prefixed to all namespace elements. It returns nil in case of success or error if building namespaces failed.
func FromMap ¶
FromMap constructs list of namespaces from multilevel map using map keys as namespace entries. 'Current' value is prefixed to all namespace elements. It returns nil in case of success or error if building namespaces failed.
func GetStructValueByNamespace ¶
func GetStructValueByNamespace(object interface{}, ns []string) interface{}
GetStructValueByNamespace returns value stored in struct composition. It requires filed tags on each struct field which may be represented as namespace component. It iterates over fields recursively, checks tags until it finds leaf value.
func GetValueByNamespace ¶
func GetValueByNamespace(object interface{}, ns []string) interface{}
GetValueByNamespace returns value stored in nested map, array or struct composition. TODO Implementation of handling complex compositions with map/slice
func ReplaceNotAllowedCharsInNamespacePart ¶
ReplaceNotAllowedCharsInNamespacePart replaces not allowed characters in namespace part by '_'
func ValidateMetricNamespacePart ¶
ValidateMetricNamespacePart checks if namespace part contains not allowed characters
Types ¶
type OptionFunc ¶
func EntryForContainersRoot ¶
func EntryForContainersRoot(flagFunc FlagFunc) OptionFunc
EntryForContainersRoot controls inserting entries for containers themselves.
If EntryForContainersRoot returns true for container at some path in ns, ns will contain entry for a container itself.
func ExportJsonFieldNames ¶
func ExportJsonFieldNames(flagFunc FlagFunc) OptionFunc
ExportJsonFieldNames option controls naming fields of struct where field is annotated with json tag.
If ExportJsonFieldNames returns true for struct at some path in ns, json name for all fields will be used rather than fields' own names. If json tag contains dash ('-') for any field, field won't be exported.
func InspectEmptyContainers ¶
func InspectEmptyContainers(flagFunc FlagFunc) OptionFunc
InspectEmptyContainers option controls NS expansion for empty maps.
If InspectEmptyContainers returns true for map at some path in ns, ns will be expanded for map's value type
func InspectNilPointers ¶
func InspectNilPointers(flagFunc FlagFunc) OptionFunc
InspectNilPointers option controls NS expansion for nil pointers.
If InspectNilPointers returns true for nil pointer at some path in ns, ns will be expanded for pointer's original type
func SanitizeNamespaceParts ¶
func SanitizeNamespaceParts(flagFunc FlagFunc) OptionFunc
SanitizeNamespaceParts controls sanitizing namespace parts in generated namespace.
If SanitizeNamespaceParts returns true for object at some path in ns, all child keys of that object (fields, map keys) will have their names sanitized, ie. all the invalid characters removed.
See also: ns.ReplaceNotAllowedCharsInNamespacePart
func WildcardEntryInContainer ¶
func WildcardEntryInContainer(flagFunc FlagFunc) OptionFunc
WildcardEntryInContainer controls adding a wildcard for inspected non-empty containers.
If WildcardEntryInContainer returns true for non-empty container (map/ slice/ array) at some path in ns, a wildcard entry will be reported for container and the containers' value type will be inspected in depth.
See also: InspectEmptyContainers