Documentation
¶
Overview ¶
Package depgraph builds the dependency graph of a project's services and walks it in (reverse) dependency order, optionally in parallel.
Index ¶
- func InDependencyOrder(ctx context.Context, project *types.Project, ...) error
- func InReverseDependencyOrder(ctx context.Context, project *types.Project, ...) error
- type Graph
- func (g *Graph) AddEdge(source string, destination string) error
- func (g *Graph) AddVertex(key string, serviceName string, initialStatus ServiceStatus)
- func (g *Graph) FilterChildren(key string, status ServiceStatus) []*Vertex
- func (g *Graph) FilterParents(key string, status ServiceStatus) []*Vertex
- func (g *Graph) HasCycles() (bool, error)
- func (g *Graph) Leaves() []*Vertex
- func (g *Graph) Roots() []*Vertex
- func (g *Graph) UpdateStatus(key string, status ServiceStatus)
- type Option
- type ServiceStatus
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Graph ¶
Graph represents project as service dependencies
func NewGraph ¶
func NewGraph(project *types.Project, initialStatus ServiceStatus) (*Graph, error)
NewGraph returns the dependency graph of the services. It never modifies the project: an optional (required: false) dependency on a service absent from the model simply contributes no edge; pruning such references from the model itself is the caller's explicit decision — see Project.WithoutUnresolvedOptionalDependencies.
func (*Graph) AddEdge ¶
AddEdge adds a relationship of dependency between vertices `source` and `destination`
func (*Graph) AddVertex ¶
func (g *Graph) AddVertex(key string, serviceName string, initialStatus ServiceStatus)
AddVertex adds a vertex to the Graph
func (*Graph) FilterChildren ¶
func (g *Graph) FilterChildren(key string, status ServiceStatus) []*Vertex
FilterChildren returns children of a certain vertex that are in a certain status
func (*Graph) FilterParents ¶
func (g *Graph) FilterParents(key string, status ServiceStatus) []*Vertex
FilterParents returns the parents of a certain vertex that are in a certain status
func (*Graph) UpdateStatus ¶
func (g *Graph) UpdateStatus(key string, status ServiceStatus)
UpdateStatus updates the status of a certain vertex
type Option ¶
type Option func(*graphTraversal)
Option customizes a dependency-order traversal.
func WithMaxConcurrency ¶
WithMaxConcurrency bounds the number of services visited concurrently (<=0 means unbounded).
func WithRootNodesAndDown ¶
WithRootNodesAndDown restricts a reverse-order traversal to the given services and the services depending on them.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus indicates the status of a service
const ( ServiceStopped ServiceStatus = iota ServiceStarted )
Services status flags
type Vertex ¶
type Vertex struct {
Key string
Service string
Status ServiceStatus
Children map[string]*Vertex
Parents map[string]*Vertex
}
Vertex represents a service in the dependencies structure
func NewVertex ¶
func NewVertex(key string, serviceName string, initialStatus ServiceStatus) *Vertex
NewVertex is the constructor function for the Vertex
func (*Vertex) GetChildren ¶
GetChildren returns a slice with the child vertices of the Vertex
func (*Vertex) GetParents ¶
GetParents returns a slice with the parent vertices of the Vertex