orchestrator

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerDefinition

type ContainerDefinition struct {
	ImageURI    string
	EnvVars     map[string]string
	Secrets     map[string]string
	Ports       map[string]string // host port -> container port
	IsEssential bool
	DependsOn   map[string]string
}

ContainerDefinition defines information necessary to run a container.

type DockerEngine

type DockerEngine interface {
	Run(context.Context, *dockerengine.RunOptions) error
	IsContainerRunning(context.Context, string) (bool, error)
	ContainerExitCode(ctx context.Context, containerName string) (int, error)
	IsContainerHealthy(ctx context.Context, containerName string) (bool, error)
	Stop(context.Context, string) error
	Build(ctx context.Context, args *dockerengine.BuildArguments, w io.Writer) error
	Exec(ctx context.Context, container string, out io.Writer, cmd string, args ...string) error
	Rm(context.Context, string) error
}

DockerEngine is used by Orchestrator to manage containers.

type Host

type Host struct {
	Name string
	Port uint16
}

Host represents a service reachable via the network.

type Orchestrator

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

Orchestrator manages running a Task. Only a single Task can be running at a time for a given Orchestrator.

func New

func New(docker DockerEngine, idPrefix string, logOptions logOptionsFunc) *Orchestrator

New creates a new Orchestrator. idPrefix is a prefix used when naming containers that are run by the Orchestrator.

func (*Orchestrator) RunTask

func (o *Orchestrator) RunTask(task Task, opts ...RunTaskOption)

RunTask stops the current running task and starts task.

func (*Orchestrator) Start

func (o *Orchestrator) Start() <-chan error

Start starts the Orchestrator. Start must be called before any other orchestrator functions. Errors from containers run by the Orchestrator or from Orchestrator actions are sent to the returned error channel. The returned error channel is closed after calling Stop() has stopped the Orchestrator. An Orchestrator should only be Started once.

func (*Orchestrator) Stop

func (o *Orchestrator) Stop()

Stop stops the current running task containers and the Orchestrator. Stop is idempotent and safe to call multiple times. Calls to RunTask() after calling Stop do nothing.

type RunTaskOption

type RunTaskOption func(*runTaskAction)

RunTaskOption adds optional data to RunTask.

func RunTaskWithProxy

func RunTaskWithProxy(ssmTarget string, network net.IPNet, hosts ...Host) RunTaskOption

RunTaskWithProxy returns a RunTaskOption that sets up a proxy connection to hosts.

type Task

type Task struct {
	Containers   map[string]ContainerDefinition
	PauseSecrets map[string]string
}

Task defines a set of Containers to be run together. Containers within a Task can talk to each other on localhost and are stopped and started as a group.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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