deployment

package
v0.0.0-...-2759aa6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorEvent  = "Error"
	FinishEvent = "Finish"
)
View Source
const (
	StartEvent           = "StartEvent"
	StartLayerDeployment = "StartLayerDeployment"
	PullImage            = "PullImage"
	CreateContainer      = "CreateContainer"
	RunHook              = "RunHook"
	StartContainer       = "StartContainer"
	FinishDeployment     = "FinishDeployment"
	ConnectDependency    = "ConnectDependency"
	AcquireSubnet        = "AcquireSubnet"
	CreateNetwork        = "CreateNetwork"
)
View Source
const Store = datadir.Store("deployments")

Variables

View Source
var (
	ErrContainerNotRunning = errors.New("container is not running")
	ErrContainerTimeout    = errors.New("container is not running (timeout)")
)
View Source
var ErrValueNotFound = errors.New("value not found")

Functions

func Deploy

func Deploy(events chan<- Event, locator *locator.Locator)

func Layered

func Layered(services map[string]*config.Service) ([][]*config.Service, error)

Layered returns the layers in which the services must be deployed.

Types

type Deployment

type Deployment struct {
	Docker *runtime.Client

	Locator *locator.Locator

	Bus       chan<- Event
	Resources sync.Map
	// contains filtered or unexported fields
}

Deployment holds the information needed to deploy a service. When updating fields, make sure to also update deploymentJSON accordingly.

func (*Deployment) Add

func (d *Deployment) Add(key, label string, value any)

Add adds a resource to the manifest under a given tag.

func (*Deployment) All

func (d *Deployment) All() map[string][]LabeledValue

func (*Deployment) Deploy

func (d *Deployment) Deploy(ctx context.Context, events chan<- Event, service *config.Service) error

Deploy deploys a service.

func (*Deployment) EnsureContainerIsRunning

func (d *Deployment) EnsureContainerIsRunning(ctx context.Context, containerID string) error

EnsureContainerIsRunning will wait for the container to start and then return an error if the container is not running after either : - 10 seconds if the container has no health-check - Retries * (Interval + Timeout) if the container has a health-check

todo(pipeline): return logs from failed container

func (*Deployment) Find

func (d *Deployment) Find(key, label string) (any, error)

func (*Deployment) Get

func (d *Deployment) Get(key string) ([]LabeledValue, error)

Get returns the resources associated with a given tag.

func (*Deployment) ID

func (d *Deployment) ID() string

func (*Deployment) MarshalJSON

func (d *Deployment) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It takes care of converting the resource map to a marshalable map.

func (*Deployment) RunHooks

func (d *Deployment) RunHooks(ctx context.Context, containerID string, commands []string) error

func (*Deployment) Time

func (d *Deployment) Time() time.Time

Time returns the time the deployment was created. todo: Add a Time property on the deployment manifest rather than using the deployment id that todo: happens to be the creation time.

func (*Deployment) UnmarshalJSON

func (d *Deployment) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. It takes care of converting the resources map to a sync.Map. Avoid using ints to the map, as they will be converted to float64s. Use strings instead.

type Event

type Event struct {
	// Service is the name of the service that the event is about.
	Service *config.Service
	// ID is an identifier unique to the kind of the event.
	ID string
	// Data is the payload of the event.
	Data any
}

func (Event) IsError

func (e Event) IsError() bool

IsError returns true if the event is an error event.

func (Event) IsFinish

func (e Event) IsFinish() bool

func (Event) IsGlobal

func (e Event) IsGlobal() bool

IsGlobal returns true if the event is not related to a service.

func (Event) Label

func (e Event) Label() string

Label returns the type of the event either 'global' or the service name.

type LabeledValue

type LabeledValue struct {
	Label string
	Value any
}

type Node

type Node struct {
	// Parent is a node that depends on this node.
	Parent *Node
	// Service is the service that this node represents.
	Service *config.Service
	// Edges is a list of nodes that this node depends on.
	Edges []*Node
	// Depth is the number of edges from the root node to this node.
	// The root node has a depth of 0.
	Depth int
}

Node contains information about a service and its position in the dependency graph.

func (*Node) AddEdge

func (n *Node) AddEdge(e *Node)

AddEdge adds a node to the list of edges.

func (*Node) Walk

func (n *Node) Walk(f func(n *Node))

Walk traverses the dependency graph in depth-first order.

Jump to

Keyboard shortcuts

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