generic

package
v3.11.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPageSize = int(25)

Functions

func Apply added in v3.11.3

func Apply(ctx context.Context, self NodeInterface, parentPath, p path.Path, options *ApplyOptions) bool

func ApplyAndGet added in v3.11.3

func ApplyAndGet(ctx context.Context, self NodeInterface, p path.Path, options *ApplyOptions) bool

func GetMappedID

func GetMappedID(ctx context.Context, origin, destinationParent NodeInterface, options *MirrorOptions) id.NodeID

func NewElementNode added in v3.10.6

func NewElementNode() path.PathElement

func NewError

func NewError[T error](message string, args ...any) T

func NewPathFromString

func NewPathFromString(pathString string) path.Path

func NodeCollectReferences

func NodeCollectReferences(ctx context.Context, node NodeInterface) []path.Path

func NodeCompare

func NodeCompare(ctx context.Context, a, b NodeInterface) bool

func NodeCopy

func NodeCopy(ctx context.Context, origin, destination NodeInterface, destinationID id.NodeID, options *MirrorOptions)

func NodeMirror

func NodeMirror(ctx context.Context, origin, destination NodeInterface, options *MirrorOptions)

func NodeParallelApply

func NodeParallelApply(ctx context.Context, origin NodeInterface, path path.Path, destination NodeInterface, options *ParallelApplyOptions) bool

func NodeUnify

func NodeUnify(ctx context.Context, origin NodeInterface, originPath path.Path, destination NodeInterface, destinationPath path.Path, options *MirrorOptions)

func NodeUnifyPath

func NodeUnifyPath(ctx context.Context, origin NodeInterface, originPath, path, destinationPath path.Path, options *MirrorOptions)

func ReadablePathString added in v3.11.5

func ReadablePathString(p path.Path) []string

func ReadableString added in v3.11.5

func ReadableString(p path.Path) string

func RegisterFactory

func RegisterFactory(name string, factory TreeFactory)

func RemapReferences

func RemapReferences(ctx context.Context, node NodeInterface, f f3.Interface)

func SetMappedID

func SetMappedID(ctx context.Context, origin, destination NodeInterface, options *MirrorOptions)

func TreeClear added in v3.11.4

func TreeClear(ctx context.Context, self TreeInterface)

func TreeCollectReferences

func TreeCollectReferences(ctx context.Context, tree TreeInterface, p path.Path) []path.Path

func TreeCompare

func TreeCompare(ctx context.Context, aTree TreeInterface, aPath path.Path, bTree TreeInterface, bPath path.Path) bool

func TreeCreateChild added in v3.11.4

func TreeCreateChild(ctx context.Context, tree TreeInterface, pathString string, set SetFunc)

func TreeMirror

func TreeMirror(ctx context.Context, originTree, destinationTree TreeInterface, path path.Path, options *MirrorOptions)

func TreeParallelApply

func TreeParallelApply(ctx context.Context, origin TreeInterface, path path.Path, destination TreeInterface, options *ParallelApplyOptions) bool

func TreePartialMirror

func TreePartialMirror(ctx context.Context, originTree TreeInterface, originPath path.Path, destinationTree TreeInterface, destinationPath path.Path, options *MirrorOptions)

func TreePathRemap

func TreePathRemap(ctx context.Context, origin TreeInterface, p path.Path, destination TreeInterface) path.Path

func TreeSetDriver added in v3.11.4

func TreeSetDriver(tree TreeInterface, driver TreeDriverInterface)

func TreeUnify

func TreeUnify(ctx context.Context, origin, destination TreeInterface, options *MirrorOptions)

func TreeUnifyPath

func TreeUnifyPath(ctx context.Context, origin TreeInterface, p path.Path, destination TreeInterface, options *MirrorOptions)

func Walk added in v3.11.3

func Walk(ctx context.Context, self NodeInterface, parent path.Path, options *WalkOptions)

func WalkAndGet added in v3.11.3

func WalkAndGet(ctx context.Context, self NodeInterface, parent path.Path, options *WalkOptions)

Types

type ApplyFunc

type ApplyFunc func(ctx context.Context, parentPath, path path.Path, node NodeInterface)

type ApplyOptions

type ApplyOptions struct {
	// contains filtered or unexported fields
}

func NewApplyOptions

func NewApplyOptions(fun ApplyFunc) *ApplyOptions

func (*ApplyOptions) SetSearch

func (o *ApplyOptions) SetSearch(search ApplySearch) *ApplyOptions

func (*ApplyOptions) SetWhere

func (o *ApplyOptions) SetWhere(where ApplyWhere) *ApplyOptions

type ApplySearch

type ApplySearch bool
const (
	ApplySearchByName ApplySearch = true
	ApplySearchByID   ApplySearch = false
)

type ApplyWhere

type ApplyWhere bool
const (
	ApplyEachNode ApplyWhere = true
	ApplyLastNode ApplyWhere = false
)

type ChildrenList added in v3.11.2

type ChildrenList []NodeInterface

func List added in v3.11.3

func List(ctx context.Context, self NodeInterface) ChildrenList

func ListPage added in v3.11.3

func ListPage(ctx context.Context, self NodeInterface, page int) ChildrenList

func NewChildrenList added in v3.11.2

func NewChildrenList(len int) ChildrenList

func (ChildrenList) String added in v3.11.4

func (o ChildrenList) String() string

type ErrorNodeNotFound

type ErrorNodeNotFound error

type ErrorRemapReferencesRelative added in v3.3.1

type ErrorRemapReferencesRelative error

type FactoryFun

type FactoryFun func(ctx context.Context, kind kind.Kind) NodeInterface

type MapIDInterface

type MapIDInterface interface {
	GetMappedID() id.NodeID
	SetMappedID(id.NodeID)
}

type MirrorDeleteFunc added in v3.11.5

type MirrorDeleteFunc func(ctx context.Context, destination NodeInterface, destinationParent path.Path)

type MirrorOptions

type MirrorOptions struct {
	// contains filtered or unexported fields
}

func NewMirrorOptions

func NewMirrorOptions(destinationTree TreeInterface) *MirrorOptions

func (*MirrorOptions) GetRename added in v3.11.5

func (o *MirrorOptions) GetRename() MirrorRenameMap

func (*MirrorOptions) Rename added in v3.11.5

func (o *MirrorOptions) Rename(kind kind.Kind, f f3.Interface)

func (*MirrorOptions) SetDelete added in v3.11.5

func (o *MirrorOptions) SetDelete(delete MirrorDeleteFunc) *MirrorOptions

func (*MirrorOptions) SetNoRemap

func (o *MirrorOptions) SetNoRemap(noremap bool) *MirrorOptions

func (*MirrorOptions) SetRename added in v3.11.5

func (o *MirrorOptions) SetRename(fromPath, toPath path.Path) *MirrorOptions

func (*MirrorOptions) SetUpsert added in v3.11.5

func (o *MirrorOptions) SetUpsert(upsert MirrorUpsertFunc) *MirrorOptions

type MirrorRenameMap added in v3.11.5

type MirrorRenameMap map[kind.Kind]map[string]string

type MirrorUpsertFunc added in v3.11.5

type MirrorUpsertFunc func(ctx context.Context, origin NodeInterface, originParent path.Path, destination NodeInterface, destinationParent path.Path)

type Node

type Node struct {
	logger.Logger
	// contains filtered or unexported fields
}

func (*Node) CreateChild

func (o *Node) CreateChild(ctx context.Context) NodeInterface

func (*Node) Delete

func (o *Node) Delete(ctx context.Context) NodeInterface

func (*Node) DeleteChild

func (o *Node) DeleteChild(id id.NodeID) NodeInterface

func (*Node) FromFormat

func (o *Node) FromFormat(f f3.Interface) NodeInterface

func (*Node) Get

func (o *Node) Get(ctx context.Context) NodeInterface

func (*Node) GetChild

func (o *Node) GetChild(id id.NodeID) NodeInterface

func (*Node) GetChildByIDOrName added in v3.11.4

func (o *Node) GetChildByIDOrName(ctx context.Context, childElement path.PathElement) NodeInterface

func (*Node) GetChildrenList added in v3.11.2

func (o *Node) GetChildrenList() ChildrenList

func (*Node) GetChildrenOrder added in v3.11.4

func (o *Node) GetChildrenOrder() []id.NodeID

func (*Node) GetCurrentPath

func (o *Node) GetCurrentPath() path.Path

func (*Node) GetDriver

func (o *Node) GetDriver() NodeDriverInterface

func (*Node) GetID

func (o *Node) GetID() id.NodeID

func (*Node) GetIDFromName

func (o *Node) GetIDFromName(ctx context.Context, name string) id.NodeID

func (*Node) GetImmutable added in v3.11.3

func (o *Node) GetImmutable() bool

func (*Node) GetIsNil

func (o *Node) GetIsNil() bool

func (*Node) GetIsSync

func (o *Node) GetIsSync() bool

func (*Node) GetKind

func (o *Node) GetKind() kind.Kind

func (*Node) GetMappedID

func (o *Node) GetMappedID() id.NodeID

func (*Node) GetName added in v3.11.4

func (o *Node) GetName() string

func (*Node) GetNodeChildren

func (o *Node) GetNodeChildren() NodeChildren

func (*Node) GetParent

func (o *Node) GetParent() NodeInterface

func (*Node) GetTree

func (o *Node) GetTree() TreeInterface

func (*Node) Init

func (o *Node) Init()

func (*Node) IsUpToDate added in v3.11.4

func (o *Node) IsUpToDate(other f3.Interface) bool

func (*Node) LookupMappedID

func (o *Node) LookupMappedID(ctx context.Context, id id.NodeID, f f3.Interface) id.NodeID

func (*Node) NewFormat

func (o *Node) NewFormat() f3.Interface

func (*Node) SetChild

func (o *Node) SetChild(child NodeInterface) NodeInterface

func (*Node) SetChildrenOrder added in v3.11.4

func (o *Node) SetChildrenOrder(childrenOrder []id.NodeID)

func (*Node) SetDriver

func (o *Node) SetDriver(driver NodeDriverInterface)

func (*Node) SetID

func (o *Node) SetID(id id.NodeID)

func (*Node) SetImmutable added in v3.11.3

func (o *Node) SetImmutable(immutable bool)

func (*Node) SetIsNil

func (o *Node) SetIsNil(isNil bool)

func (*Node) SetIsSync

func (o *Node) SetIsSync(sync bool)

func (*Node) SetKind

func (o *Node) SetKind(kind kind.Kind)

func (*Node) SetMappedID

func (o *Node) SetMappedID(mapped id.NodeID)

func (*Node) SetNodeChildren added in v3.11.2

func (o *Node) SetNodeChildren(children NodeChildren)

func (*Node) SetParent

func (o *Node) SetParent(parent NodeInterface)

func (*Node) SetTree

func (o *Node) SetTree(tree TreeInterface)

func (*Node) String

func (o *Node) String() string

func (*Node) ToFormat

func (o *Node) ToFormat() f3.Interface

func (*Node) Upsert

func (o *Node) Upsert(ctx context.Context) NodeInterface

type NodeAccessorsInterface

type NodeAccessorsInterface interface {
	SetIsNil(bool)
	GetIsNil() bool

	SetImmutable(bool)
	GetImmutable() bool

	SetIsSync(bool)
	GetIsSync() bool

	GetParent() NodeInterface
	SetParent(NodeInterface)

	GetKind() kind.Kind
	SetKind(kind.Kind)

	GetID() id.NodeID
	SetID(id.NodeID)

	GetTree() TreeInterface
	SetTree(TreeInterface)

	GetChildrenOrder() []id.NodeID
	SetChildrenOrder([]id.NodeID)

	GetNodeChildren() NodeChildren
	SetNodeChildren(NodeChildren)
	GetChildrenList() ChildrenList

	GetDriver() NodeDriverInterface
	SetDriver(NodeDriverInterface)
}

type NodeChildren

type NodeChildren map[id.NodeID]NodeInterface

func NewNodeChildren

func NewNodeChildren() NodeChildren

type NodeDriverInterface

type NodeDriverInterface interface {
	logger.MessageInterface

	MapIDInterface

	IsNull() bool

	GetNode() NodeInterface
	SetNode(NodeInterface)

	SetTreeDriver(treeDriver TreeDriverInterface)
	GetTreeDriver() TreeDriverInterface

	ListPage(context.Context, NodeInterface, int) ChildrenList
	GetIDFromName(context.Context, string) id.NodeID

	IsUpToDate(f3.Interface) bool

	Get(context.Context) bool
	Put(context.Context) id.NodeID
	Patch(context.Context)
	Delete(context.Context)

	NewFormat() f3.Interface
	FromFormat(f3.Interface)
	ToFormat() f3.Interface

	LookupMappedID(context.Context, id.NodeID, f3.Interface) id.NodeID

	String() string
}

func NewNullDriver

func NewNullDriver() NodeDriverInterface

type NodeDriverProxyInterface

type NodeDriverProxyInterface interface {
	MapIDInterface
	GetIDFromName(context.Context, string) id.NodeID
	GetChildByIDOrName(context.Context, path.PathElement) NodeInterface

	Get(context.Context) NodeInterface
	Upsert(context.Context) NodeInterface
	Delete(context.Context) NodeInterface

	NewFormat() f3.Interface
	FromFormat(f3.Interface) NodeInterface
	ToFormat() f3.Interface
	GetName() string
	IsUpToDate(f3.Interface) bool

	LookupMappedID(context.Context, id.NodeID, f3.Interface) id.NodeID
}

type NodeInterface

var (
	NilNode   NodeInterface = &Node{isNil: true}
	NilParent               = NilNode
)

func Find added in v3.11.3

func Find(self NodeInterface, p path.Path) NodeInterface

func FindAndGet added in v3.11.3

func FindAndGet(ctx context.Context, self NodeInterface, p path.Path) NodeInterface

func FindByIDOrName added in v3.11.4

func FindByIDOrName(ctx context.Context, self NodeInterface, p path.Path) NodeInterface

func MustFind added in v3.11.3

func MustFind(self NodeInterface, p path.Path) NodeInterface

func NewNode

func NewNode() NodeInterface

func NewNodeFromID

func NewNodeFromID(i string) NodeInterface

func NodeFactory added in v3.11.4

func NodeFactory(ctx context.Context, self TreeInterface, kind kind.Kind) NodeInterface

func NodeUnifyOne

func NodeUnifyOne(ctx context.Context, origin NodeInterface, originPath, path, destinationPath path.Path, options *MirrorOptions) NodeInterface

type NodeTreeInterface

type NodeTreeInterface interface {
	GetChild(id.NodeID) NodeInterface
	GetIDFromName(context.Context, string) id.NodeID
	SetChild(NodeInterface) NodeInterface
	DeleteChild(id.NodeID) NodeInterface
	CreateChild(context.Context) NodeInterface

	GetCurrentPath() path.Path
}

type NullDriver

type NullDriver struct {
	logger.Logger
	// contains filtered or unexported fields
}

func (*NullDriver) Delete

func (o *NullDriver) Delete(context.Context)

func (*NullDriver) FromFormat

func (o *NullDriver) FromFormat(f3.Interface)

func (*NullDriver) Get

func (o *NullDriver) Get(context.Context) bool

func (*NullDriver) GetIDFromName

func (o *NullDriver) GetIDFromName(ctx context.Context, name string) id.NodeID

func (*NullDriver) GetMappedID

func (o *NullDriver) GetMappedID() id.NodeID

func (*NullDriver) GetNode

func (o *NullDriver) GetNode() NodeInterface

func (*NullDriver) GetTreeDriver

func (o *NullDriver) GetTreeDriver() TreeDriverInterface

func (*NullDriver) IsNull

func (o *NullDriver) IsNull() bool

func (*NullDriver) IsUpToDate added in v3.11.4

func (o *NullDriver) IsUpToDate(other f3.Interface) bool

func (*NullDriver) ListPage

func (o *NullDriver) ListPage(ctx context.Context, node NodeInterface, page int) ChildrenList

func (*NullDriver) LookupMappedID

func (o *NullDriver) LookupMappedID(_ context.Context, _ id.NodeID, _ f3.Interface) id.NodeID

func (*NullDriver) NewFormat

func (o *NullDriver) NewFormat() f3.Interface

func (*NullDriver) Patch

func (o *NullDriver) Patch(context.Context)

func (*NullDriver) Put

func (*NullDriver) SetMappedID

func (o *NullDriver) SetMappedID(mapped id.NodeID)

func (*NullDriver) SetNode

func (o *NullDriver) SetNode(node NodeInterface)

func (*NullDriver) SetTreeDriver

func (o *NullDriver) SetTreeDriver(treeDriver TreeDriverInterface)

func (*NullDriver) String

func (o *NullDriver) String() string

func (*NullDriver) ToFormat

func (o *NullDriver) ToFormat() f3.Interface

type NullTreeDriver

type NullTreeDriver struct {
	logger.Logger
	// contains filtered or unexported fields
}

func (*NullTreeDriver) AllocateID

func (o *NullTreeDriver) AllocateID() bool

func (*NullTreeDriver) Diff

func (*NullTreeDriver) Factory

func (*NullTreeDriver) GetPageSize

func (o *NullTreeDriver) GetPageSize() int

func (*NullTreeDriver) GetTree

func (o *NullTreeDriver) GetTree() TreeInterface

func (*NullTreeDriver) Init

func (o *NullTreeDriver) Init()

func (*NullTreeDriver) SetPageSize

func (o *NullTreeDriver) SetPageSize(pageSize int)

func (*NullTreeDriver) SetTree

func (o *NullTreeDriver) SetTree(tree TreeInterface)

type ParallelApplyFunc

type ParallelApplyFunc func(ctx context.Context, origin, destination NodeInterface)

type ParallelApplyOptions

type ParallelApplyOptions struct {
	// contains filtered or unexported fields
}

func NewParallelApplyOptions

func NewParallelApplyOptions(fun ParallelApplyFunc) *ParallelApplyOptions

func (*ParallelApplyOptions) SetNoRemap

func (o *ParallelApplyOptions) SetNoRemap(noremap bool) *ParallelApplyOptions

func (*ParallelApplyOptions) SetWhere

type SetFunc added in v3.11.4

type SetFunc func(parent path.Path, node NodeInterface)

type Tree

type Tree struct {
	logger.Logger
	// contains filtered or unexported fields
}

func (*Tree) AllocateID

func (o *Tree) AllocateID() bool

func (*Tree) Apply

func (o *Tree) Apply(ctx context.Context, p path.Path, options *ApplyOptions) bool

func (*Tree) ApplyAndGet

func (o *Tree) ApplyAndGet(ctx context.Context, path path.Path, options *ApplyOptions) bool

func (*Tree) Diff

func (o *Tree) Diff(a, b NodeInterface) string

func (*Tree) Exists

func (o *Tree) Exists(ctx context.Context, path path.Path) bool

func (*Tree) Find

func (o *Tree) Find(path path.Path) NodeInterface

func (*Tree) FindAndGet

func (o *Tree) FindAndGet(ctx context.Context, path path.Path) NodeInterface

func (*Tree) FindByIDOrName added in v3.11.4

func (o *Tree) FindByIDOrName(ctx context.Context, path path.Path) NodeInterface

func (*Tree) GetChildrenKind

func (o *Tree) GetChildrenKind(parentKind kind.Kind) kind.Kind

func (*Tree) GetDriver

func (o *Tree) GetDriver() TreeDriverInterface

func (*Tree) GetFactory added in v3.11.4

func (o *Tree) GetFactory(kind kind.Kind) FactoryFun

func (*Tree) GetOptions

func (o *Tree) GetOptions() options.Interface

func (*Tree) GetPageSize

func (o *Tree) GetPageSize() int

func (*Tree) GetRoot

func (o *Tree) GetRoot() NodeInterface

func (*Tree) Init

func (o *Tree) Init(opts options.Interface)

func (*Tree) MustFind

func (o *Tree) MustFind(path path.Path) NodeInterface

func (*Tree) SetDriver

func (o *Tree) SetDriver(driver TreeDriverInterface)

func (*Tree) SetFactory added in v3.11.4

func (o *Tree) SetFactory(kind kind.Kind, factory FactoryFun)

func (*Tree) SetOptions

func (o *Tree) SetOptions(opts options.Interface)

func (*Tree) SetRoot

func (o *Tree) SetRoot(root NodeInterface)

func (*Tree) Walk

func (o *Tree) Walk(ctx context.Context, options *WalkOptions)

func (*Tree) WalkAndGet

func (o *Tree) WalkAndGet(ctx context.Context, options *WalkOptions)

type TreeDriverInterface

type TreeDriverInterface interface {
	logger.Interface

	GetTree() TreeInterface
	SetTree(TreeInterface)

	GetPageSize() int
	SetPageSize(int)

	AllocateID() bool

	Init()

	Diff(a, b NodeDriverInterface) string

	Factory(ctx context.Context, kind kind.Kind) NodeDriverInterface
}

func NewNullTreeDriver

func NewNullTreeDriver() TreeDriverInterface

type TreeFactory

type TreeFactory func(ctx context.Context, opts options.Interface) TreeInterface

func GetFactory

func GetFactory(name string) TreeFactory

type TreeInterface

type TreeInterface interface {
	logger.Interface

	Init(options.Interface)

	GetOptions() options.Interface
	SetOptions(options.Interface)

	SetRoot(NodeInterface)
	GetRoot() NodeInterface

	SetLogger(logger.Interface)
	GetLogger() logger.Interface

	GetDriver() TreeDriverInterface
	SetDriver(TreeDriverInterface)

	SetFactory(kind kind.Kind, factory FactoryFun)
	GetFactory(kind kind.Kind) FactoryFun

	GetChildrenKind(kind.Kind) kind.Kind

	GetPageSize() int

	AllocateID() bool

	Diff(a, b NodeInterface) string

	MustFind(path.Path) NodeInterface
	Find(path.Path) NodeInterface
	FindByIDOrName(ctx context.Context, path path.Path) NodeInterface
	FindAndGet(context.Context, path.Path) NodeInterface
	Exists(context.Context, path.Path) bool

	Walk(context.Context, *WalkOptions)
	WalkAndGet(context.Context, *WalkOptions)
	Apply(context.Context, path.Path, *ApplyOptions) bool
	ApplyAndGet(context.Context, path.Path, *ApplyOptions) bool
}

func NewTree

func NewTree(opts options.Interface) TreeInterface

type WalkFunc

type WalkFunc func(context.Context, path.Path, NodeInterface)

type WalkOptions

type WalkOptions struct {
	// contains filtered or unexported fields
}

func NewWalkOptions

func NewWalkOptions(fun WalkFunc) *WalkOptions

Jump to

Keyboard shortcuts

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