Documentation
¶
Index ¶
- func FilterDeleted(l *LeafEntry) bool
- func FilterDeletedNotExplicitDelete(l *LeafEntry) bool
- func FilterNew(l *LeafEntry) bool
- func FilterNonDeleted(l *LeafEntry) bool
- func FilterNonDeletedButNewOrUpdated(l *LeafEntry) bool
- func FilterUpdated(l *LeafEntry) bool
- func HighestPrecedenceFilterAll(le *LeafEntry) bool
- func HighestPrecedenceFilterWithoutDeleted(le *LeafEntry) bool
- func HighestPrecedenceFilterWithoutNew(le *LeafEntry) bool
- func LeafEntriesToUpdates(l []*LeafEntry) []*types.Update
- func RegisterEntryFactory(factory EntryFactory)
- func Unfiltered(l *LeafEntry) bool
- type ChildMap
- func (c *ChildMap) AddOrGet(e Entry) Entry
- func (c *ChildMap) DeleteChild(name string)
- func (c *ChildMap) DeleteChilds(names []string)
- func (c *ChildMap) ForEach(fn func(name string, e Entry))
- func (c *ChildMap) GetAll() map[string]Entry
- func (c *ChildMap) GetAllSorted() []Entry
- func (c *ChildMap) GetEntry(s string) (e Entry, exists bool)
- func (c *ChildMap) GetKeys() []string
- func (c *ChildMap) Length() int
- func (c *ChildMap) SortedKeys() []string
- type ChoiceResolvers
- type DeletePathPrio
- type DeletePathSet
- func (dp *DeletePathSet) Add(intentName string, prio int32, pathset *sdcpb.PathSet)
- func (dp *DeletePathSet) DeepCopy() *DeletePathSet
- func (dp *DeletePathSet) GetByIntentName(intentName string) *sdcpb.PathSet
- func (dp *DeletePathSet) Items() iter.Seq[*DeletePathPrio]
- func (dp *DeletePathSet) Remove(intentName string) *sdcpb.PathSet
- type DescendMethod
- type Entry
- type EntryFactory
- type EntryMap
- type HighestPrecedenceFilter
- type LeafEntry
- func (l *LeafEntry) Compare(other *LeafEntry) int
- func (l *LeafEntry) DeepCopy(parentEntry Entry) *LeafEntry
- func (l *LeafEntry) DropDeleteFlag() *LeafEntry
- func (l *LeafEntry) Equal(other *LeafEntry) bool
- func (l *LeafEntry) GetDeleteFlag() bool
- func (l *LeafEntry) GetDeleteOnlyIntendedFlag() bool
- func (l *LeafEntry) GetEntry() Entry
- func (l *LeafEntry) GetExplicitDeleteFlag() bool
- func (l *LeafEntry) GetNewFlag() bool
- func (l *LeafEntry) GetUpdate() *types.Update
- func (l *LeafEntry) GetUpdateFlag() bool
- func (l *LeafEntry) MarkDelete(onlyIntended bool)
- func (l *LeafEntry) MarkExpliciteDelete()
- func (l *LeafEntry) MarkNew()
- func (l *LeafEntry) MarkUpdate(u *types.Update)
- func (l *LeafEntry) NonRevertive() bool
- func (l *LeafEntry) String() string
- type LeafEntryFilter
- type LeafVariantSlice
- func (lvs LeafVariantSlice) Equal(otherLvs LeafVariantSlice) (bool, error)
- func (lvs LeafVariantSlice) String() string
- func (lvs LeafVariantSlice) ToPathAndUpdateSlice() []*types.PathAndUpdate
- func (lvs LeafVariantSlice) ToSdcpbUpdateSlice() []*sdcpb.Update
- func (lvs LeafVariantSlice) ToUpdateSlice() types.UpdateSlice
- type LeafVariants
- func (lv *LeafVariants) Add(le *LeafEntry)
- func (lv *LeafVariants) AddExplicitDeleteEntry(intentName string, priority int32) *LeafEntry
- func (lv *LeafVariants) AddWithStats(le *LeafEntry, stats *types.ImportStats)
- func (lv *LeafVariants) CanDelete() bool
- func (lv *LeafVariants) CanDeleteBranch(keepDefault bool) bool
- func (lv *LeafVariants) DeepCopy(tc TreeContext, parent Entry) *LeafVariants
- func (lv *LeafVariants) DeleteByOwner(owner string) *LeafEntry
- func (lv *LeafVariants) GetByOwner(owner string) *LeafEntry
- func (lv *LeafVariants) GetDeviations(ctx context.Context, ch chan<- *types.DeviationEntry, isActiveCase bool)
- func (lv *LeafVariants) GetHighestPrecedence(onlyNewOrUpdated bool, includeDefaults bool, includeExplicitDelete bool) *LeafEntry
- func (lv *LeafVariants) GetHighestPrecedenceValue(filter HighestPrecedenceFilter) int32
- func (lv *LeafVariants) GetRunning() *LeafEntry
- func (lv *LeafVariants) Items() iter.Seq[*LeafEntry]
- func (lv *LeafVariants) Length() int
- func (lv *LeafVariants) MarkOwnerForDeletion(owner string, onlyIntended bool) *LeafEntry
- func (lv *LeafVariants) RemainsToExist() bool
- func (lv *LeafVariants) RemoveDeletedByOwner(owner string) *LeafEntry
- func (lv *LeafVariants) ResetFlags(deleteFlag bool, newFlag bool, updatedFlag bool) int
- func (lv *LeafVariants) ShouldDelete() bool
- type NonRevertiveInfo
- func (n *NonRevertiveInfo) AddPaths(path ...*sdcpb.Path) *NonRevertiveInfo
- func (n *NonRevertiveInfo) DeepCopy() *NonRevertiveInfo
- func (n *NonRevertiveInfo) IsGenerallyNonRevertive() bool
- func (n *NonRevertiveInfo) IsNonRevertive(p SdcpbPath) bool
- func (n *NonRevertiveInfo) SetNonRevertive(nonRevertive bool)
- func (n *NonRevertiveInfo) String() string
- type NonRevertiveInfos
- func (n NonRevertiveInfos) Add(owner string, nonRevertive bool, paths ...*sdcpb.Path)
- func (n NonRevertiveInfos) DeepCopy() NonRevertiveInfos
- func (n NonRevertiveInfos) IsGenerallyNonRevertive(owner string) bool
- func (n NonRevertiveInfos) IsNonRevertive(owner string, path SdcpbPath) bool
- func (n NonRevertiveInfos) String() string
- type SdcpbPath
- type TreeContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterDeleted ¶
FilterDeleted Accepts all Entries that are marked as deleted
func FilterNonDeleted ¶
FilterNonDeleted Accepts all Entries that are not marked as deleted
func FilterNonDeletedButNewOrUpdated ¶
FilterNonDeletedButNewOrUpdated Accepts all Entries that are New or Updated and not Deleted.
func FilterUpdated ¶
FilterUpdated Accepts all entries that are updates
func LeafEntriesToUpdates ¶
LeafEntriesToCacheUpdates
func RegisterEntryFactory ¶
func RegisterEntryFactory(factory EntryFactory)
RegisterEntryFactory registers the factory function for creating Entry instances This is called by the tree package during initialization
func Unfiltered ¶
Unfiltered accepts all entries without any filtering
Types ¶
type ChildMap ¶
type ChildMap struct {
// contains filtered or unexported fields
}
func NewChildMap ¶
func NewChildMap() *ChildMap
func NewChildMapWithEntries ¶
NewChildMapWithEntries creates a ChildMap with initial entries (for testing)
func (*ChildMap) AddOrGet ¶
AddOrGet adds the entry if no entry with the same path name exists. If an entry already exists, it returns the existing (canonical) entry. This provides a safe get-or-create primitive for concurrent callers.
func (*ChildMap) DeleteChild ¶
func (*ChildMap) DeleteChilds ¶
func (*ChildMap) GetAllSorted ¶
func (*ChildMap) SortedKeys ¶
SortedKeys returns the keys of the child map in sorted order
type ChoiceResolvers ¶
type ChoiceResolvers map[string]*choiceResolver
func (ChoiceResolvers) AddChoice ¶
func (c ChoiceResolvers) AddChoice(name string) *choiceResolver
AddChoice adds / registers a new Choice to the choiceCasesResolver
func (ChoiceResolvers) DeepCopy ¶
func (c ChoiceResolvers) DeepCopy() ChoiceResolvers
func (ChoiceResolvers) GetDeletes ¶
func (c ChoiceResolvers) GetDeletes() []string
GetDeletes returns the names of the elements that need to be deleted.
func (ChoiceResolvers) GetSkipElements ¶
func (c ChoiceResolvers) GetSkipElements() []string
GetSkipElements returns the list of all choices elements that are not highes priority. The resulting slice is used to skip these elements.
type DeletePathPrio ¶
type DeletePathPrio struct {
// contains filtered or unexported fields
}
func NewDeletePathPrio ¶
func NewDeletePathPrio(owner string, prio int32) *DeletePathPrio
func (*DeletePathPrio) DeepCopy ¶
func (ddp *DeletePathPrio) DeepCopy() *DeletePathPrio
func (*DeletePathPrio) GetOwner ¶
func (dpp *DeletePathPrio) GetOwner() string
func (*DeletePathPrio) GetPathSet ¶
func (dpp *DeletePathPrio) GetPathSet() *sdcpb.PathSet
func (*DeletePathPrio) GetPrio ¶
func (dpp *DeletePathPrio) GetPrio() int32
type DeletePathSet ¶
type DeletePathSet struct {
// contains filtered or unexported fields
}
func NewDeletePaths ¶
func NewDeletePaths() *DeletePathSet
func (*DeletePathSet) Add ¶
func (dp *DeletePathSet) Add(intentName string, prio int32, pathset *sdcpb.PathSet)
func (*DeletePathSet) DeepCopy ¶
func (dp *DeletePathSet) DeepCopy() *DeletePathSet
func (*DeletePathSet) GetByIntentName ¶
func (dp *DeletePathSet) GetByIntentName(intentName string) *sdcpb.PathSet
func (*DeletePathSet) Items ¶
func (dp *DeletePathSet) Items() iter.Seq[*DeletePathPrio]
type DescendMethod ¶
type DescendMethod int
const ( DescendMethodAll DescendMethod = iota DescendMethodActiveChilds )
type Entry ¶
type Entry interface {
// PathName returns the last Path element, the name of the Entry
PathName() string
// GetLevel returns the depth of the Entry in the tree
GetLevel() int
// AddOrGetChild adds a child entry or returns the existing one if it already exists
AddOrGetChild(context.Context, Entry) (Entry, error)
// StringIndent debug tree struct as indented string slice
StringIndent(result []string) []string
// GetSchema returns the *sdcpb.SchemaElem of the Entry
GetSchema() *sdcpb.SchemaElem
// IsRoot returns true if the Entry is the root of the tree
IsRoot() bool
// FinishInsertionPhase indicates, that the insertion of Entries into the tree is over
// Hence calculations for e.g. choice/case can be performed.
FinishInsertionPhase(ctx context.Context) error
// GetParent returns the parent entry
GetParent() Entry
// SdcpbPath returns the sdcpb.Path struct for the Entry
SdcpbPath() *sdcpb.Path
// // // GetSchemaKeys checks for the schema of the entry, and returns the defined keys
// // GetSchemaKeys() []string
// // GetRootBasedEntryChain returns all the entries starting from the root down to the actual Entry.
// GetRootBasedEntryChain() []Entry
// remainsToExist indicates if a LeafEntry for this entry will survive the update.
// Since we add running to the tree, there will always be Entries, that will disappear in the
// as part of the SetIntent process. We need to consider this, when evaluating e.g. LeafRefs.
// The returned boolean will in indicate if the value remains existing (true) after the setintent.
// Or will disappear from device (running) as part of the update action.
RemainsToExist() bool
// shouldDelete returns true if an explicit delete should be issued for the given branch
ShouldDelete() bool
// canDelete checks if the entry can be Deleted.
// This is e.g. to cover e.g. defaults and running. They can be deleted, but should not, they are basically implicitly existing.
// In caomparison to
// - remainsToExists() returns true, because they remain to exist even though implicitly.
// - shouldDelete() returns false, because no explicit delete should be issued for them.
CanDelete() bool
GetChildMap() *ChildMap
GetChilds(types.DescendMethod) EntryMap
// // DeleteBranch Deletes from the tree, all elements of the PathSlice defined branch of the given owner
// DeleteBranch(ctx context.Context, path *sdcpb.Path, owner string) (err error)
// GetListChilds collects all the childs of the list. In the tree we store them seperated into their key branches.
// this is collecting all the last level key entries.
// GetListChilds() ([]Entry, error)
DeepCopy(tc TreeContext, parent Entry) (Entry, error)
GetLeafVariants() *LeafVariants
CanDeleteBranch(keepDefault bool) bool
DeleteCanDeleteChilds(keepDefault bool)
// GetTreeContext returns the TreeContext of the Entry, which holds global information about the tree
// and is used for certain operations that require access to this global information.
GetTreeContext() TreeContext
// ChoicesResolvers returns the choice case resolvers for the entry, if any
ChoicesResolvers() ChoiceResolvers
}
Entry is the primary Element of the Tree.
type EntryFactory ¶
type EntryFactory func(ctx context.Context, parent Entry, pathElemName string, tc TreeContext) (Entry, error)
EntryFactory is a function type for creating new Entry instances
type EntryMap ¶
func (EntryMap) SortedKeys ¶
type HighestPrecedenceFilter ¶
type LeafEntry ¶
type LeafEntry struct {
*types.Update
IsNew bool
Delete bool
DeleteOnlyIntended bool
IsUpdated bool
IsExplicitDelete bool
// contains filtered or unexported fields
}
LeafEntry stores the *cache.Update along with additional attributes. These Attributes indicate if the entry is to be deleted / added (new) or updated.
func NewLeafEntry ¶
NewLeafEntry constructor for a new LeafEntry
func (*LeafEntry) Compare ¶
Compare used for slices.SortFunc. Sorts by path and if equal paths then by owner as the second criteria
func (*LeafEntry) DropDeleteFlag ¶
func (*LeafEntry) GetDeleteFlag ¶
func (*LeafEntry) GetDeleteOnlyIntendedFlag ¶
func (*LeafEntry) GetExplicitDeleteFlag ¶
func (*LeafEntry) GetNewFlag ¶
func (*LeafEntry) GetUpdateFlag ¶
func (*LeafEntry) MarkDelete ¶
MarkDelete indicate that the entry is to be deleted
func (*LeafEntry) MarkExpliciteDelete ¶
func (l *LeafEntry) MarkExpliciteDelete()
MarkExpliciteDelete indicate that the entry is to be explicitely deleted
func (*LeafEntry) MarkUpdate ¶
MarkUpdate indicate that the entry is an Updated value
func (*LeafEntry) NonRevertive ¶
type LeafEntryFilter ¶
type LeafVariantSlice ¶
type LeafVariantSlice []*LeafEntry
func (LeafVariantSlice) Equal ¶
func (lvs LeafVariantSlice) Equal(otherLvs LeafVariantSlice) (bool, error)
Equal checks equality of the LeafVariantSlice with the other LeafVariantSlice
func (LeafVariantSlice) String ¶
func (lvs LeafVariantSlice) String() string
func (LeafVariantSlice) ToPathAndUpdateSlice ¶
func (lvs LeafVariantSlice) ToPathAndUpdateSlice() []*types.PathAndUpdate
func (LeafVariantSlice) ToSdcpbUpdateSlice ¶
func (lvs LeafVariantSlice) ToSdcpbUpdateSlice() []*sdcpb.Update
func (LeafVariantSlice) ToUpdateSlice ¶
func (lvs LeafVariantSlice) ToUpdateSlice() types.UpdateSlice
type LeafVariants ¶
type LeafVariants struct {
// contains filtered or unexported fields
}
func NewLeafVariants ¶
func NewLeafVariants(tc TreeContext, parentEnty Entry) *LeafVariants
func (*LeafVariants) Add ¶
func (lv *LeafVariants) Add(le *LeafEntry)
func (*LeafVariants) AddExplicitDeleteEntry ¶
func (lv *LeafVariants) AddExplicitDeleteEntry(intentName string, priority int32) *LeafEntry
func (*LeafVariants) AddWithStats ¶
func (lv *LeafVariants) AddWithStats(le *LeafEntry, stats *types.ImportStats)
func (*LeafVariants) CanDelete ¶
func (lv *LeafVariants) CanDelete() bool
CanDelete returns true if leafValues exist that are not owned by default or running that do not have the DeleteFlag set [or if delete is set, also the DeleteOnlyIntendedFlag set]
func (*LeafVariants) CanDeleteBranch ¶
func (lv *LeafVariants) CanDeleteBranch(keepDefault bool) bool
func (*LeafVariants) DeepCopy ¶
func (lv *LeafVariants) DeepCopy(tc TreeContext, parent Entry) *LeafVariants
func (*LeafVariants) DeleteByOwner ¶
func (lv *LeafVariants) DeleteByOwner(owner string) *LeafEntry
func (*LeafVariants) GetByOwner ¶
func (lv *LeafVariants) GetByOwner(owner string) *LeafEntry
GetByOwner returns the entry that is owned by the given owner, returns nil if no entry exists.
func (*LeafVariants) GetDeviations ¶
func (lv *LeafVariants) GetDeviations(ctx context.Context, ch chan<- *types.DeviationEntry, isActiveCase bool)
func (*LeafVariants) GetHighestPrecedence ¶
func (lv *LeafVariants) GetHighestPrecedence(onlyNewOrUpdated bool, includeDefaults bool, includeExplicitDelete bool) *LeafEntry
GetHighesNewUpdated returns the LeafEntry with the highes priority nil if no leaf entry exists.
func (*LeafVariants) GetHighestPrecedenceValue ¶
func (lv *LeafVariants) GetHighestPrecedenceValue(filter HighestPrecedenceFilter) int32
func (*LeafVariants) GetRunning ¶
func (lv *LeafVariants) GetRunning() *LeafEntry
func (*LeafVariants) Items ¶
func (lv *LeafVariants) Items() iter.Seq[*LeafEntry]
Items iterator for the LeafVariants
func (*LeafVariants) Length ¶
func (lv *LeafVariants) Length() int
func (*LeafVariants) MarkOwnerForDeletion ¶
func (lv *LeafVariants) MarkOwnerForDeletion(owner string, onlyIntended bool) *LeafEntry
MarkOwnerForDeletion searches for a LefVariant of given owner, if it exists the entry is marked for deletion. returning the leafentry if an owner entry was found, nil if not.
func (*LeafVariants) RemainsToExist ¶
func (lv *LeafVariants) RemainsToExist() bool
func (*LeafVariants) RemoveDeletedByOwner ¶
func (lv *LeafVariants) RemoveDeletedByOwner(owner string) *LeafEntry
RemoveDeletedByOwner removes and returns the LeafEntry owned by the given owner if it is marked for deletion.
func (*LeafVariants) ResetFlags ¶
func (lv *LeafVariants) ResetFlags(deleteFlag bool, newFlag bool, updatedFlag bool) int
func (*LeafVariants) ShouldDelete ¶
func (lv *LeafVariants) ShouldDelete() bool
ShouldDelete evaluates the LeafVariants and indicates if the overall result is, that the Entry referencing these LeafVariants is explicitly to be deleted. Meaning there are no other LeafVariants remaining after the pending action, that any LeafVariant other then Running or Defaults exist.
type NonRevertiveInfo ¶
type NonRevertiveInfo struct {
// contains filtered or unexported fields
}
func NewNonRevertiveInfo ¶
func NewNonRevertiveInfo(intentName string, nonRevertive bool) *NonRevertiveInfo
func (*NonRevertiveInfo) AddPaths ¶
func (n *NonRevertiveInfo) AddPaths(path ...*sdcpb.Path) *NonRevertiveInfo
func (*NonRevertiveInfo) DeepCopy ¶
func (n *NonRevertiveInfo) DeepCopy() *NonRevertiveInfo
func (*NonRevertiveInfo) IsGenerallyNonRevertive ¶
func (n *NonRevertiveInfo) IsGenerallyNonRevertive() bool
IsGenerallyNonRevertive returns the general non-revertive state of the intent, which is true if the intent is non-revertive for all paths, false otherwise.
func (*NonRevertiveInfo) IsNonRevertive ¶
func (n *NonRevertiveInfo) IsNonRevertive(p SdcpbPath) bool
IsNonRevertive returns true if the intent is non-revertive for the given path, false otherwise. If no paths are set for the intent, the general non-revertive state is returned.
func (*NonRevertiveInfo) SetNonRevertive ¶
func (n *NonRevertiveInfo) SetNonRevertive(nonRevertive bool)
func (*NonRevertiveInfo) String ¶
func (n *NonRevertiveInfo) String() string
type NonRevertiveInfos ¶
type NonRevertiveInfos map[string]*NonRevertiveInfo
func NewNonRevertiveInfos ¶
func NewNonRevertiveInfos() NonRevertiveInfos
func (NonRevertiveInfos) Add ¶
func (n NonRevertiveInfos) Add(owner string, nonRevertive bool, paths ...*sdcpb.Path)
func (NonRevertiveInfos) DeepCopy ¶
func (n NonRevertiveInfos) DeepCopy() NonRevertiveInfos
func (NonRevertiveInfos) IsGenerallyNonRevertive ¶
func (n NonRevertiveInfos) IsGenerallyNonRevertive(owner string) bool
func (NonRevertiveInfos) IsNonRevertive ¶
func (n NonRevertiveInfos) IsNonRevertive(owner string, path SdcpbPath) bool
func (NonRevertiveInfos) String ¶
func (n NonRevertiveInfos) String() string
type TreeContext ¶
type TreeContext interface {
PoolFactory() pool.VirtualPoolFactory
SchemaClient() schemaClient.SchemaClientBound
DeepCopy() TreeContext
ExplicitDeletes() *DeletePathSet
NonRevertiveInfo() NonRevertiveInfos
}