local

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 52 Imported by: 1

Documentation

Index

Constants

View Source
const (

	//ComposeVersion Compose version
	ComposeVersion = "1.0-alpha"
)

Variables

This section is empty.

Functions

func InDependencyOrder

func InDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, types.ServiceConfig) error) error

InDependencyOrder applies the function to the services of the project taking in account the dependency order

func InReverseDependencyOrder

func InReverseDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, types.ServiceConfig) error) error

InReverseDependencyOrder applies the function to the services of the project in reverse order of dependencies

Types

type Graph

type Graph struct {
	Vertices map[string]*Vertex
	// contains filtered or unexported fields
}

Graph represents project as service dependencies

func NewGraph

func NewGraph(services types.Services, initialStatus ServiceStatus) *Graph

NewGraph returns the dependency graph of the services

func (*Graph) AddEdge

func (g *Graph) AddEdge(source string, destination string) error

AddEdge adds a relationship of dependency between vertexes `source` and `destination`

func (*Graph) AddVertex

func (g *Graph) AddVertex(key string, service types.ServiceConfig, 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) HasCycles

func (g *Graph) HasCycles() (bool, error)

HasCycles detects cycles in the graph

func (*Graph) Leaves

func (g *Graph) Leaves() []*Vertex

Leaves returns the slice of leaves of the graph

func (*Graph) Roots

func (g *Graph) Roots() []*Vertex

Roots returns the slice of "Roots" of the graph

func (*Graph) UpdateStatus

func (g *Graph) UpdateStatus(key string, status ServiceStatus)

UpdateStatus updates the status of a certain vertex

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  types.ServiceConfig
	Status   ServiceStatus
	Children map[string]*Vertex
	Parents  map[string]*Vertex
}

Vertex represents a service in the dependencies structure

func NewVertex

func NewVertex(key string, service types.ServiceConfig, initialStatus ServiceStatus) *Vertex

NewVertex is the constructor function for the Vertex

func (*Vertex) GetChildren

func (v *Vertex) GetChildren() []*Vertex

GetChildren returns a slice with the child vertexes of the a Vertex

func (*Vertex) GetParents

func (v *Vertex) GetParents() []*Vertex

GetParents returns a slice with the parent vertexes of the a Vertex

Jump to

Keyboard shortcuts

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