compose

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 64 Imported by: 0

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

func NewComposeService

func NewComposeService(apiClient client.APIClient, configFile *configfile.ConfigFile) compose.Service

NewComposeService create a local implementation of the compose.Service API

Types

type Containers added in v1.0.7

type Containers []moby.Container

Containers is a set of moby Container

type ContainersKey added in v1.0.9

type ContainersKey struct{}

ContainersKey is the context key to access context value os a ContainersStatus

type ContainersState added in v1.0.9

type ContainersState interface {
	Get(string) *types.Container
	GetContainers() Containers
	Add(c types.Container)
	AddAll(cs Containers)
	Remove(string) types.Container
}

ContainersState state management interface

func GetContextContainerState added in v1.0.9

func GetContextContainerState(ctx context.Context) (ContainersState, error)

GetContextContainerState gets the container state manager

func NewContainersState added in v1.0.9

func NewContainersState(cs Containers) ContainersState

NewContainersState creates a new container state manager

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