toposort

package
v7.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toposort provides a topological sort for segments/flags based on their dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(allData []st.Collection) []st.Collection

Sort performs a topological sort on the given data collections, so that the items can be inserted into a persistent store to minimize the risk of evaluating a flag before its prerequisites/segments have been stored.

Types

type AdjacencyList

type AdjacencyList map[Vertex]Neighbors

AdjacencyList is a map of vertices (kind/key) to neighbors (dependencies).

type DependencyTracker added in v7.15.5

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

DependencyTracker maintains a bidirectional dependency graph that can be updated whenever an item has changed.

A nearly identical unexported implementation exists in internal/datasource for the FDv1 code path; that copy will go away when FDv1 is removed.

func NewDependencyTracker added in v7.15.5

func NewDependencyTracker() *DependencyTracker

NewDependencyTracker creates a DependencyTracker with an empty dependency graph.

func (*DependencyTracker) AddAffectedItems added in v7.15.5

func (d *DependencyTracker) AddAffectedItems(itemsOut Neighbors, initialModifiedItem Vertex)

AddAffectedItems populates the given set with the union of the initial item and all items that directly or indirectly depend on it (based on the current state of the dependency graph).

func (*DependencyTracker) Reset added in v7.15.5

func (d *DependencyTracker) Reset()

Reset clears the dependency graph.

func (*DependencyTracker) UpdateDependenciesFrom added in v7.15.5

func (d *DependencyTracker) UpdateDependenciesFrom(
	kind st.DataKind,
	fromKey string,
	fromItem st.ItemDescriptor,
)

UpdateDependenciesFrom updates the dependency graph when an item has changed.

type Neighbors

type Neighbors map[Vertex]struct{}

Neighbors is a set of vertices. It is used instead of a list for efficient lookup.

func GetNeighbors

func GetNeighbors(kind st.DataKind, fromItem st.ItemDescriptor) Neighbors

GetNeighbors returns all direct neighbors of the given item.

func (Neighbors) Add

func (s Neighbors) Add(value Vertex)

Add adds a vertex to the set.

func (Neighbors) Contains

func (s Neighbors) Contains(value Vertex) bool

Contains returns true if the set contains the vertex.

type Vertex

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

Vertex represents a particular data item, identified by kind + key.

func NewVertex

func NewVertex(kind st.DataKind, key string) Vertex

NewVertex constructs a Vertex.

func (Vertex) Key

func (v Vertex) Key() string

Key returns the key of the vertex.

func (Vertex) Kind

func (v Vertex) Kind() st.DataKind

Kind returns the data kind of the vertex.

Jump to

Keyboard shortcuts

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