backend

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2016 License: MIT Imports: 42 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStaleVM is returned from one of the Instance methods if it detects
	// that the VM had already been used for a repository and was not reverted
	// afterwards.
	ErrStaleVM = fmt.Errorf("previous build artifacts found on stale vm")

	// ErrMissingEndpointConfig is returned if the provider config was missing
	// an 'ENDPOINT' configuration, but one is required.
	ErrMissingEndpointConfig = fmt.Errorf("expected config key endpoint")
)

Functions

func EachBackend added in v1.3.0

func EachBackend(f func(*Backend))

EachBackend calls a given function for each registered backend

func Register added in v1.3.0

func Register(alias, humanReadableName string, providerHelp map[string]string, providerFunc func(*config.ProviderConfig) (Provider, error))

Register adds a backend to the registry!

Types

type Backend added in v1.3.0

type Backend struct {
	Alias             string
	HumanReadableName string
	ProviderHelp      map[string]string
	ProviderFunc      func(*config.ProviderConfig) (Provider, error)
}

Backend wraps up an alias, backend provider help, and a factory func for a given backend provider wheee

type Instance

type Instance interface {
	// UploadScript uploads the given script to the instance. The script is
	// a bash script with a shebang (#!/bin/bash) line. Note that this
	// method should not be called multiple times.
	UploadScript(context.Context, []byte) error

	// RunScript runs the build script that was uploaded with the
	// UploadScript method.
	RunScript(context.Context, io.Writer) (*RunResult, error)
	Stop(context.Context) error

	// ID is used when identifying the instance in logs and such
	ID() string

	// StartupDuration is the duration between "created" and "ready"
	StartupDuration() time.Duration
}

An Instance is something that can run a build script.

type Provider

type Provider interface {
	// Setup performs whatever is necessary in order to be ready to start
	// instances.
	Setup(context.Context) error

	// Start starts an instance. It shouldn't return until the instance is
	// ready to call UploadScript on (this may, for example, mean that it
	// waits for SSH connections to be possible).
	Start(context.Context, *StartAttributes) (Instance, error)
}

Provider represents some kind of instance provider. It can point to an external HTTP API, or some process locally, or something completely different.

func NewBackendProvider added in v1.3.0

func NewBackendProvider(alias string, cfg *config.ProviderConfig) (Provider, error)

NewBackendProvider looks up a backend by its alias and returns a provider via the factory func on the registered *Backend

type RunResult

type RunResult struct {
	// The exit code of the script. Only valid if Completed is true.
	ExitCode uint8

	// Whether the script finished running or not. Can be false if there was a
	// connection error in the middle of the script run.
	Completed bool
}

RunResult represents the result of running a script with Instance.RunScript.

type StartAttributes

type StartAttributes struct {
	Language string `json:"language"`
	OsxImage string `json:"osx_image"`
	Dist     string `json:"dist"`
	Group    string `json:"group"`
	OS       string `json:"os"`

	// The VMType isn't stored in the config directly, but in the top level of
	// the job payload, see the worker.JobPayload struct.
	VMType string `json:"-"`
}

StartAttributes contains some parts of the config which can be used to determine the type of instance to boot up (for example, what image to use)

func (*StartAttributes) SetDefaults added in v1.3.0

func (sa *StartAttributes) SetDefaults(lang, dist, group, os, vmType string)

SetDefaults sets any missing required attributes to the default values provided

Jump to

Keyboard shortcuts

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