twelvefactor

package
v0.13.0-clearcare-2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package scheduler provides the core interface that Empire uses when interacting with a cluster of machines to run tasks.

Index

Constants

This section is empty.

Variables

View Source
var NullStatusStream = StatusStreamFunc(func(status Status) error {
	return nil
})

NullStatusStream a status stream that does nothing.

Functions

func Env

func Env(app *Manifest, process *Process) map[string]string

Env merges the App environment with any environment variables provided in the process.

func Labels

func Labels(app *Manifest, process *Process) map[string]string

Labels merges the App labels with any labels provided in the process.

Types

type CRONSchedule

type CRONSchedule string

CRONSchedule is a Schedule implementation that represents a CRON expression.

type Exposure

type Exposure struct {
	// External means that this process will be exposed to internet facing
	// traffic, as opposed to being internal. How this is used is
	// implementation specific. For ECS, this means that the attached ELB
	// will be "internet-facing".
	External bool

	// The ports to expose and map to the container.
	Ports []Port
}

Exposure controls the exposure settings for a process.

type HTTP

type HTTP struct{}

HTTP represents an HTTP exposure.

func (*HTTP) Protocol

func (e *HTTP) Protocol() string

type HTTPS

type HTTPS struct {
	// The certificate to attach to the process.
	Cert string
}

HTTPS represents an HTTPS exposure

func (*HTTPS) Protocol

func (e *HTTPS) Protocol() string

type Host

type Host struct {
	// The host ID.
	ID string
}

Host represents the host of an instance

type Manifest

type Manifest struct {
	// The id of the app.
	AppID string

	// An identifier that represents the version of this release.
	Release string

	// The name of the app.
	Name string

	// The application environment.
	Env map[string]string

	// The application labels.
	Labels map[string]string

	// Process that belong to this app.
	Processes []*Process
}

type Port

type Port struct {
	// The port that external applications will connect to. It's
	// implementation specific as to what this is used for. For example,
	// with ECS, this is used as the LoadBalancerPort.
	Host int

	// The port within the container that the process should bind to.
	Container int

	// The exposure type (e.g. HTTPExposure, HTTPSExposure, TCPExposure).
	Protocol Protocol
}

Port maps a host port to a container port.

type Process

type Process struct {
	// The type of process.
	Type string

	// The Image to run.
	Image image.Image

	// The Command to run.
	Command []string

	// Environment variables to set.
	Env map[string]string

	// Labels to set on the container.
	Labels map[string]string

	// The amount of RAM to allocate to this process in bytes.
	Memory uint

	// The amount of CPU to allocate to this process, out of 1024. Maps to
	// the --cpu-shares flag for docker.
	CPUShares uint

	// ulimit -u
	Nproc uint

	// Quantity is the desired instances of this service to run.
	Quantity int

	// Exposure is the level of exposure for this process.
	Exposure *Exposure

	// Can be used to setup a CRON schedule to run this task periodically.
	Schedule Schedule

	// Any ECS specific configuration.
	ECS *procfile.ECS

	// Input/Output streams.
	Stdin          io.Reader
	Stdout, Stderr io.Writer
}

type Protocol

type Protocol interface {
	Protocol() string
}

Protocol represents a service that a process exposes, like HTTP/HTTPS/TCP or SSL.

type SSL

type SSL struct {
	// The certificate to attach to the process.
	Cert string
}

SSL represents a secure TCP exposure

func (*SSL) Protocol

func (e *SSL) Protocol() string

type Schedule

type Schedule interface{}

Schedule represents a Schedule for scheduled tasks that run periodically.

type Scheduler

type Scheduler interface {
	// Run runs a process.
	Run(ctx context.Context, app *Manifest) error

	// Submit submits an app, creating it or updating it as necessary.
	// When StatusStream is nil, Submit should return as quickly as possible,
	// usually when the new version has been received, and validated. If
	// StatusStream is not nil, it's recommended that the method not return until
	// the deployment has fully completed.
	Submit(context.Context, *Manifest, StatusStream) error

	// Remove removes the App.
	Remove(ctx context.Context, app string) error

	// Instance lists the instances of a Process for an app.
	Tasks(ctx context.Context, app string) ([]*Task, error)

	// Stop stops an instance. The scheduler will automatically start a new
	// instance.
	Stop(ctx context.Context, instanceID string) error

	// Restart restarts the processes within the App.
	Restart(context.Context, string, StatusStream) error
}

Scheduler is an interface for interfacing with Services.

func Transform

func Transform(s Scheduler, fn func(*Manifest) *Manifest) Scheduler

Trasnform wraps a Scheduler to perform transformations on the Manifest. This can be used to, for example, add defaults placement constraints before providing it to the backend scheduler.

type Status

type Status struct {
	// A friendly human readable message about the status change.
	Message string
}

func (*Status) String

func (s *Status) String() string

String implements the fmt.Stringer interface.

type StatusStream

type StatusStream interface {
	// Publish publishes an update to the status stream
	Publish(Status) error
}

StatusStream is an interface for publishing status updates while a scheduler is executing.

type StatusStreamFunc

type StatusStreamFunc func(Status) error

StatusStreamFunc is a function that implements the Statusstream interface

func (StatusStreamFunc) Publish

func (fn StatusStreamFunc) Publish(status Status) error

type TCP

type TCP struct{}

TCP represents a tcp exposure.

func (*TCP) Protocol

func (e *TCP) Protocol() string

type Task

type Task struct {
	Process *Process

	// The instance ID.
	ID string

	// The instance host
	Host Host

	// The State that this Instance is in.
	State string

	// The time that this instance was last updated.
	UpdatedAt time.Time
}

Task represents an Task of a Process.

Jump to

Keyboard shortcuts

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