scheduler

package
v0.11.1 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 exposure type (e.g. HTTPExposure, HTTPSExposure, TCPExposure).
	Type ExposureType
}

Exposure controls the exposure settings for a process.

type ExposureType added in v0.10.1

type ExposureType interface {
	Protocol() string
}

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

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

type HTTPExposure struct{}

HTTPExposure represents an HTTP exposure.

func (*HTTPExposure) Protocol added in v0.10.1

func (e *HTTPExposure) Protocol() string

type HTTPSExposure added in v0.10.1

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

HTTPSExposure represents an HTTPS exposure

func (*HTTPSExposure) Protocol added in v0.10.1

func (e *HTTPSExposure) Protocol() string

type Instance

type Instance struct {
	Process *Process

	// The instance ID.
	ID string

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

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

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

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
Pacakge ecs provides an implementation of the Scheduler interface that uses Amazon EC2 Container Service.
Pacakge ecs provides an implementation of the Scheduler interface that uses Amazon EC2 Container Service.
lb
package lb provides an abstraction around creating load balancers.
package lb provides an abstraction around creating load balancers.
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