scheduler

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2017 License: BSD-2-Clause Imports: 8 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 added in v0.10.1

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

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

func Labels added in v0.10.1

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

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

func Publish added in v0.11.0

func Publish(ctx context.Context, stream StatusStream, msg string)

Types

type App

type App struct {
	// The id of the app.
	ID 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 CRONSchedule added in v0.11.0

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 FakeScheduler

type FakeScheduler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFakeScheduler

func NewFakeScheduler() *FakeScheduler

func (*FakeScheduler) Instances

func (m *FakeScheduler) Instances(ctx context.Context, appID string) ([]*Instance, error)

func (*FakeScheduler) Remove

func (m *FakeScheduler) Remove(ctx context.Context, appID string) error

func (*FakeScheduler) Restart added in v0.11.0

func (m *FakeScheduler) Restart(ctx context.Context, app *App, ss StatusStream) error

func (*FakeScheduler) Run

func (m *FakeScheduler) Run(ctx context.Context, app *App, p *Process, in io.Reader, out io.Writer) error

func (*FakeScheduler) Scale

func (m *FakeScheduler) Scale(ctx context.Context, app string, ptype string, instances uint) error

func (*FakeScheduler) Stop

func (m *FakeScheduler) Stop(ctx context.Context, instanceID string) error

func (*FakeScheduler) Submit

func (m *FakeScheduler) Submit(ctx context.Context, app *App, ss StatusStream) error

type HTTP added in v0.12.0

type HTTP struct{}

HTTP represents an HTTP exposure.

func (*HTTP) Protocol added in v0.12.0

func (e *HTTP) Protocol() string

type HTTPS added in v0.12.0

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

HTTPS represents an HTTPS exposure

func (*HTTPS) Protocol added in v0.12.0

func (e *HTTPS) Protocol() string

type Host added in v0.12.0

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

Host represents the host of an instance

type Instance

type Instance 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
}

Instance represents an Instance of a Process.

type Port added in v0.12.0

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.
	MemoryLimit 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

	// Instances is the desired instances of this service to run.
	Instances uint

	// 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
}

type Protocol added in v0.12.0

type Protocol interface {
	Protocol() string
}

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

type Runner

type Runner interface {
	// Run runs a process.
	Run(ctx context.Context, app *App, process *Process, in io.Reader, out io.Writer) error
}

type SSL added in v0.12.0

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

SSL represents a secure TCP exposure

func (*SSL) Protocol added in v0.12.0

func (e *SSL) Protocol() string

type Schedule added in v0.11.0

type Schedule interface{}

Schedule represents a Schedule for scheduled tasks that run periodically.

type Scheduler

type Scheduler interface {
	Runner

	// 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, *App, StatusStream) error

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

	// Instance lists the instances of a Process for an app.
	Instances(ctx context.Context, app string) ([]*Instance, 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, *App, StatusStream) error
}

Scheduler is an interface for interfacing with Services.

type Status added in v0.11.0

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

func (*Status) String added in v0.11.0

func (s *Status) String() string

String implements the fmt.Stringer interface.

type StatusStream added in v0.11.0

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 added in v0.11.0

type StatusStreamFunc func(Status) error

StatusStreamFunc is a function that implements the Statusstream interface

func (StatusStreamFunc) Publish added in v0.11.0

func (fn StatusStreamFunc) Publish(status Status) error

type TCP added in v0.12.0

type TCP struct{}

TCP represents a tcp exposure.

func (*TCP) Protocol added in v0.12.0

func (e *TCP) Protocol() string

Directories

Path Synopsis
Package cloudformation implements the Scheduler interface for ECS by using CloudFormation to provision and update resources.
Package cloudformation implements the Scheduler interface for ECS by using CloudFormation to provision and update resources.
Package docker implements the Scheduler interface backed by the Docker API.
Package docker implements the Scheduler interface backed by the Docker API.
ecs
lb
Package kubernetes implements the Scheduler interface backed by Kubernetes.
Package kubernetes implements the Scheduler interface backed by Kubernetes.

Jump to

Keyboard shortcuts

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