Documentation
¶
Index ¶
- Variables
- type Directive
- type Forest
- type Tree
- func NewJSONTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyCacheJSONTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
- func NewLazyCacheTOMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
- func NewLazyCacheTileTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
- func NewLazyCacheTree[R Directive](driver driver.Driver, name, template string, ttl time.Duration, ...) (Tree, error)
- func NewLazyCacheXMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
- func NewLazyCacheYAMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
- func NewLazyInstantJSONTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyInstantTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyInstantTileTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyInstantTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
- func NewLazyInstantXMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyInstantYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyJSONTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyTileTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
- func NewLazyXMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewLazyYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewTileTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
- func NewXMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- func NewYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)
- type TreeBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExistsTree tree not exists ErrNotExistsTree = errors.New("tree not exists") // ErrRateLimited rate limited ErrRateLimited = errors.New("rate limited") )
Functions ¶
This section is empty.
Types ¶
type Directive ¶
type Directive interface {
// Path returns the path this directive applies to.
Path() string
// Processors returns the processors for this directive.
Processors() []driver.Processor
}
Directive defines a path and the processors to apply at that path.
type Forest ¶
type Forest interface {
Register(...TreeBuilder)
Append(...TreeBuilder) Forest
Build() Forest
// Refresh refreshes all trees.
// interval is optional and only first value is useful when set.
// Blocks when the interval is set.
Refresh(interval ...time.Duration)
// RefreshTree refreshes the specified tree.
RefreshTree(name string)
Get(name string) Tree
Set(tree Tree)
// GetVal retrieves a value from the named tree at the given path.
GetVal(treeName, path string) (val []byte, err error)
// GetValWithContext retrieves a value with runtime context.
GetValWithContext(rc *driver.RealizeContext, treeName, path string) (val []byte, err error)
Info() string
// SetRateLimit sets a global rate limit for all GetVal calls as a fallback.
SetRateLimit(r rate.Limit, burst int)
// SetDefaultContext sets the default RealizeContext on all trees in the forest.
SetDefaultContext(rc *driver.RealizeContext)
}
Forest manages a collection of trees.
func NewForest ¶
func NewForest(builders ...TreeBuilder) Forest
NewForest builds a new forest and returns it.
type Tree ¶
type Tree interface {
// Name returns the tree name.
Name() string
// Path returns the tree path in the root tree.
// Returns "" when the tree is the root tree.
Path() string
// Set adds or updates a directive on the tree.
Set(Directive) error
// Get retrieves the value at the given path.
Get(path string) (val []byte, err error)
// GetWithContext retrieves a value with runtime context for dynamic construction.
GetWithContext(rc *driver.RealizeContext, path string) (val []byte, err error)
// Has checks if a node exists at the given path.
Has(path string) bool
// Del deletes a node at the given path.
Del(path string) error
// Graft attaches a sub-tree.
Graft(Tree)
// ShowStruct returns the tree structure as JSON.
ShowStruct() []byte
// SetRateLimit sets a rate limit for Get calls on this tree.
SetRateLimit(r rate.Limit, burst int)
// SetFallback sets a processor to handle cases where path resolution
// cannot find a matching child node.
SetFallback(proc driver.Processor)
// SetDefaultContext sets the default RealizeContext used by realize when
// no request-scoped context is provided (e.g. via Get or during build).
SetDefaultContext(rc *driver.RealizeContext)
}
Tree is a hierarchical node structure with path-based access.
func NewJSONTree ¶
NewJSONTree builds a JSON tree.
func NewLazyCacheJSONTree ¶
func NewLazyCacheJSONTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheJSONTree builds a lazy JSON tree with cache TTL.
func NewLazyCacheTOMLTree ¶
func NewLazyCacheTOMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheTOMLTree builds a lazy TOML tree with cache TTL.
func NewLazyCacheTileTree ¶
func NewLazyCacheTileTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheTileTree builds a lazy cache tile tree.
func NewLazyCacheTree ¶
func NewLazyCacheTree[R Directive](driver driver.Driver, name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheTree builds a lazy tree with cache TTL. After the TTL expires, the next Get() triggers re-realization.
func NewLazyCacheXMLTree ¶
func NewLazyCacheXMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheXMLTree builds a lazy XML tree with cache TTL.
func NewLazyCacheYAMLTree ¶
func NewLazyCacheYAMLTree[R Directive](name, template string, ttl time.Duration, directives ...R) (Tree, error)
NewLazyCacheYAMLTree builds a lazy YAML tree with cache TTL.
func NewLazyInstantJSONTree ¶
NewLazyInstantJSONTree builds a lazy instant JSON tree.
func NewLazyInstantTOMLTree ¶
NewLazyInstantTOMLTree builds a lazy instant TOML tree.
func NewLazyInstantTileTree ¶
NewLazyInstantTileTree builds a lazy instant tile tree.
func NewLazyInstantTree ¶
func NewLazyInstantTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
NewLazyInstantTree builds a lazy instant tree.
func NewLazyInstantXMLTree ¶
NewLazyInstantXMLTree builds a lazy instant XML tree.
func NewLazyInstantYAMLTree ¶
NewLazyInstantYAMLTree builds a lazy instant YAML tree.
func NewLazyJSONTree ¶
NewLazyJSONTree builds a lazy JSON tree.
func NewLazyTOMLTree ¶
NewLazyTOMLTree builds a lazy TOML tree.
func NewLazyTileTree ¶
NewLazyTileTree builds a lazy tile tree.
func NewLazyTree ¶
func NewLazyTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
NewLazyTree builds a lazy tree.
func NewLazyXMLTree ¶
NewLazyXMLTree builds a lazy XML tree.
func NewLazyYAMLTree ¶
NewLazyYAMLTree builds a lazy YAML tree.
func NewTOMLTree ¶
NewTOMLTree builds a TOML tree.
func NewTileTree ¶
NewTileTree builds a tile tree.
func NewTree ¶
func NewTree[R Directive](driver driver.Driver, name, template string, directives ...R) (Tree, error)
NewTree builds a standard tree.
func NewXMLTree ¶
NewXMLTree builds an XML tree.