cproto

package
v0.750.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	// ContainerIP is the IP address from inside the container.
	ContainerIP string `json:"container_ip"`
	// ContainerPort is the port from inside the container.
	ContainerPort int `json:"container_port"`

	// HostIP is the IP address from outside the container. This can be
	// different than the ContainerIP because of network forwarding on the host
	// machine.
	HostIP string `json:"host_ip"`
	// HostPort is the IP port from outside the container. This can be different
	// than the ContainerPort because of network forwarding on the host machine.
	HostPort int `json:"host_port"`
}

Address represents an exposed port on a container.

func (*Address) Proto

func (a *Address) Proto() *taskv1.Address

Proto returns the proto representation of address.

func (Address) String

func (a Address) String() string

type CheckConfig

type CheckConfig struct {
	// Port specifies the port inside the container that the service is listening on.
	Port int
	// Path specifies the path to request over HTTP (not including the '/' right after the host/port).
	Path string
}

CheckConfig describes the configuration for an HTTP readiness check.

type ChecksConfig

type ChecksConfig struct {
	// PeriodSeconds is how long in seconds to wait between successive checks.
	PeriodSeconds float64
	// Checks describes all the checks that must pass for a container to be considered ready.
	Checks []CheckConfig
}

ChecksConfig describes the configuration for multiple readiness checks.

type Container

type Container struct {
	ID          ID              `json:"id"`
	State       State           `json:"state"`
	Devices     []device.Device `json:"devices"`
	Description string          `json:"description"` // This gets mapped to Docker labels, 63 chars.
}

Container tracks a container running in the cluster.

func (*Container) DeepCopy

func (c *Container) DeepCopy() *Container

DeepCopy returns a deep copy of the container.

func (Container) DeviceUUIDsByType

func (c Container) DeviceUUIDsByType(deviceType device.Type) (uuids []string)

DeviceUUIDsByType returns the UUIDs of the devices with the given device type.

func (*Container) ToProto

func (c *Container) ToProto() *containerv1.Container

ToProto returns the proto representation of the container.

func (Container) Transition

func (c Container) Transition(new State) Container

Transition transitions the container state to the new state. An illegal transition will panic.

type ID

type ID string

ID is a unique ID assigned to the containers of tasks when started in the cluster.

func NewID

func NewID() ID

NewID provides a unique ID for a container.

func (ID) MarshalText

func (id ID) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (*ID) Scan

func (id *ID) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (ID) String

func (id ID) String() string

String implements the fmt.Stringer interface.

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type PullSpec

type PullSpec struct {
	ForcePull bool
	Registry  *registry.AuthConfig
}

PullSpec contains configs for an ImagePull call.

type RunArchive

type RunArchive struct {
	Path        string
	Archive     archive.Archive
	CopyOptions types.CopyToContainerOptions
}

RunArchive contains one set of files sent over per CopyToContainer call.

type RunSpec

type RunSpec struct {
	ContainerConfig  container.Config
	HostConfig       container.HostConfig
	NetworkingConfig network.NetworkingConfig

	Archives   []RunArchive
	DeviceType device.Type
	Registry   *registry.AuthConfig
}

RunSpec contains configs for ContainerCreate, CopyToContainer, and ContainerStart calls.

type Spec

type Spec struct {
	TaskType string
	PullSpec PullSpec
	RunSpec  RunSpec
}

Spec provides the necessary information for an agent to start a container.

type State

type State string

State represents the current state of the container.

const (
	// Assigned state means that the container has been assigned to an agent but has not started
	// yet.
	Assigned State = "ASSIGNED"
	// Pulling state means that the container's base image is being pulled from the Docker registry.
	Pulling State = "PULLING"
	// Starting state means that the image has been pulled and the container is being started, but
	// the container is not ready yet.
	Starting State = "STARTING"
	// Running state means that the service in the container is running.
	Running State = "RUNNING"
	// Terminated state means that the container has exited or has been aborted.
	Terminated State = "TERMINATED"
	// Unknown state is a null value.
	Unknown State = ""
)

func ParseStateFromDocker

func ParseStateFromDocker(cont types.Container) (State, error)

ParseStateFromDocker parses raw docker state into our state.

func (State) Before

func (s State) Before(other State) bool

Before returns true if our state comes before or is equal to another. Callers have an implicit assumption that states always transition in order.

func (State) MarshalText

func (s State) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (State) Proto

func (s State) Proto() containerv1.State

Proto returns the proto representation of the container state.

func (State) String

func (s State) String() string

func (*State) UnmarshalText

func (s *State) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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