ivy

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 11 Imported by: 0

README

ivy

Hierarchical content-construction engine

  • TODO:
    • query hook

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

func NewDirective

func NewDirective(path string, Processors ...driver.Processor) Directive

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

func NewJSONTree[R Directive](name, template string, directives ...R) (Tree, error)

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

func NewLazyInstantJSONTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyInstantJSONTree builds a lazy instant JSON tree.

func NewLazyInstantTOMLTree

func NewLazyInstantTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyInstantTOMLTree builds a lazy instant TOML tree.

func NewLazyInstantTileTree

func NewLazyInstantTileTree[R Directive](name, template string, directives ...R) (Tree, error)

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

func NewLazyInstantXMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyInstantXMLTree builds a lazy instant XML tree.

func NewLazyInstantYAMLTree

func NewLazyInstantYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyInstantYAMLTree builds a lazy instant YAML tree.

func NewLazyJSONTree

func NewLazyJSONTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyJSONTree builds a lazy JSON tree.

func NewLazyTOMLTree

func NewLazyTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyTOMLTree builds a lazy TOML tree.

func NewLazyTileTree

func NewLazyTileTree[R Directive](name, template string, directives ...R) (Tree, error)

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

func NewLazyXMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyXMLTree builds a lazy XML tree.

func NewLazyYAMLTree

func NewLazyYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewLazyYAMLTree builds a lazy YAML tree.

func NewTOMLTree

func NewTOMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewTOMLTree builds a TOML tree.

func NewTileTree

func NewTileTree[R Directive](name, template string, directives ...R) (Tree, error)

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

func NewXMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewXMLTree builds an XML tree.

func NewYAMLTree

func NewYAMLTree[R Directive](name, template string, directives ...R) (Tree, error)

NewYAMLTree builds a YAML tree.

type TreeBuilder

type TreeBuilder func() Tree

TreeBuilder tree build method

Directories

Path Synopsis
cmd
serve command

Jump to

Keyboard shortcuts

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