nodetreemodel

package module
v0.61.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Overview

Package nodetreemodel defines a model for the config using a tree of nodes

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound is an error for when a key is not found

Functions

func NewConfig

func NewConfig(name string, envPrefix string, envKeyReplacer *strings.Replacer) model.Config

NewConfig returns a new Config object.

Types

type InnerNode added in v0.60.0

type InnerNode interface {
	Node
	HasChild(string) bool
	ChildrenKeys() []string
	Merge(InnerNode) error
	SetAt([]string, interface{}, model.Source) (bool, error)
	InsertChildNode(string, Node)

	DumpSettings(func(model.Source) bool) map[string]interface{}
	// contains filtered or unexported methods
}

InnerNode represents an inner node in the config

type LeafNode added in v0.60.0

type LeafNode interface {
	Node
	Get() interface{}
	Source() model.Source
	SourceGreaterOrEqual(model.Source) bool
}

LeafNode represents a leaf node of the config

type Node added in v0.60.0

type Node interface {
	Clone() Node
	GetChild(string) (Node, error)
}

Node represents a arbitrary node

func NewNodeTree added in v0.61.0

func NewNodeTree(v interface{}, source model.Source) (Node, error)

NewNodeTree will recursively create nodes from the input value to construct a tree

type NodeTreeConfig added in v0.60.0

type NodeTreeConfig interface {
	GetNode(string) (Node, error)
}

NodeTreeConfig is an interface that gives access to nodes

type NodeType added in v0.60.0

type NodeType int

NodeType represents node types in the tree (ie: inner or leaf)

const (
	// InnerType is a inner node in the config
	InnerType NodeType = iota
	// LeafType is a leaf node in the config
	LeafType
	// MissingType is a none-object representing when a child node is missing
	MissingType
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL