task

package
v0.0.0-...-de46e54 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

The Task: Is the smallest unit of work in an Orchestration system and typically runs in a container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AttachStderr  bool
	AttachStdin   bool
	AttachStdout  bool
	Cmd           []string
	Disk          int64
	Env           []string
	Image         string
	Memory        int64
	Name          string
	RestartPolicy string // Accepted values: always, unless-stopped, on-failure and empty.
}

Config: The Config type represents the configuration for orchestration tasks.

type Docker

type Docker struct {
	Client      DockerApi
	Config      Config
	ContainerId string
	// contains filtered or unexported fields
}

Docker: The Docker type will encapsulate everything we need to run a task in a container.

func NewDocker

func NewDocker(client DockerApi) *Docker

NewDocker: The NewDocker function returns a new Docker.

func (*Docker) Run

func (d *Docker) Run() DockerResult

Run: The Run function runs a task in a container.

type DockerApi

type DockerApi interface {
	ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error)
	ContainerStart(ctx context.Context, id string, opts types.ContainerStartOptions) error
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
}

DockerApi: The DockerApi type represents the interface for the Docker API.

type DockerResult

type DockerResult struct {
	Action      string
	ContainerId string
	Error       error
	Result      string
}

DockerResult: The DockerResult type represents the result of running a task in a container.

type State

type State int

State: The State type represents the states a task goes through, from Pending to Scheduled to Running to Completed or Failed.

const (
	Pending State = iota
	Scheduled
	Running
	Completed
	Failed
)

type Task

type Task struct {
	Disk          int
	ExposedPorts  nat.PortSet
	FinishTime    time.Time
	ID            uuid.UUID
	Image         string
	Memory        int
	Name          string
	PortBindings  map[string]string
	RestartPolicy string
	StartTime     time.Time
	State         State
}

Task: The Task type represents a task that is to be run in a container.

type TaskEvent

type TaskEvent struct {
	ID        uuid.UUID
	State     State
	Timestamp time.Time
	Task      Task
}

TaskEvent: The TaskEvent type represents an event that is emitted when a task changes state.

Jump to

Keyboard shortcuts

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