scaley

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package scaley provides the domain objects, interfaces, and workflows for scaling server groups on Engine Yard Cloud.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Finalize

func Finalize(result dry.Result) error

Finalize is the last step of all scaley runs. It takes a dry.Result with an embedded scaling event and handles things like cleanup, logging of event completion, and so on. If the scaling event failed, an error is returned. Otherwise, nil is returned.

func Scale

func Scale() *dry.Transaction

Scale is a factory that produces a new Transaction that can be called with Call.

Types

type CannotLoadGroup

type CannotLoadGroup struct {
	GroupName string
	Err       error
}

CannotLoadGroup is an error that is raised when the group data cannot be read from its data source.

func (CannotLoadGroup) Error

func (e CannotLoadGroup) Error() string

type ChefFailure

type ChefFailure struct {
	Group       *Group
	Environment *Environment
}

ChefFailure is an error that is raised when an attempt to reconfigure an environment fails.

func (ChefFailure) Error

func (e ChefFailure) Error() string

type Direction

type Direction int

Direction describes the desired direction (up, down, none) for a scaling event.

const (
	// None indicates that no scaling event should occur.
	None Direction = iota
	// Down indicates that the group should be scaled down.
	Down
	// Up indicates that the group should be scaled up.
	Up
)

func (Direction) DesiredState

func (d Direction) DesiredState() string

DesiredState returns the state that a server should be in for scaling to be considered for a given direction.

func (Direction) String

func (d Direction) String() string

String returns a text representation of a direction.

type Environment

type Environment struct {
	ID   string
	Name string
}

Environment is a representation of an Engine Yard Cloud environment.

type EnvironmentService

type EnvironmentService interface {
	Get(string) (*Environment, error)
	Configure(*Environment) error
}

EnvironmentService is an interface that describes an object that knows how to interact with an Environment.

type ExecService

type ExecService interface {
	Run(string) int
}

ExecService is an interface that describes an object that knows how to execute external commands.

type Group

type Group struct {
	Name                   string   `yaml:"name"`
	ScalingServers         []string `yaml:"scaling_servers"`
	ScalingScript          string   `yaml:"scaling_script"`
	StopScript             string   `yaml:"stop_script"`
	IgnoreStopScriptErrors bool     `yaml:"ignore_stop_script_errors"`
	Strategy               string   `yaml:"strategy"`
}

Group is a representation of a scaling group.

type GroupIsLocked

type GroupIsLocked struct {
	Group *Group
}

GroupIsLocked is an error that is raised when the group associated with a scaling event is already locked for scaling operations.

func (GroupIsLocked) Error

func (e GroupIsLocked) Error() string

type GroupService

type GroupService interface {
	Get(string) (*Group, error)
}

GroupService is an interface that describes an object that knows how to interact with a Group.

type InvalidEnvironment

type InvalidEnvironment struct {
	Group *Group
}

InvalidEnvironment is an error that is raised when the environment associated with a scaling script's group cannot be loaded from the Engine Yard API.

func (InvalidEnvironment) Error

func (e InvalidEnvironment) Error() string

type InvalidScalingServer

type InvalidScalingServer struct {
	Group  *Group
	Server string
}

InvalidScalingServer is an error that is raised when a group contains a scaling server that cannot be found on the upstream Engine Yard API.

func (InvalidScalingServer) Error

func (e InvalidScalingServer) Error() string

type LockFailure

type LockFailure struct {
	Group *Group
}

LockFailure is an error that is raised when an attempt to lock a group fails.

func (LockFailure) Error

func (e LockFailure) Error() string

type LockService

type LockService interface {
	Lock(*Group) error
	Unlock(*Group) error
	Locked(*Group) bool
}

LockService is an interface that describes an object that knows how to deal with Group locking.

type LogService

type LogService interface {
	Info(*Group, string)
	Failure(*Group, string)
	Success(*Group, string)
}

LogService is an interface that describes an object that provides logging capabilities.

type MissingScalingScript

type MissingScalingScript struct {
	Group *Group
}

MissingScalingScript is an error that is raised when a group's configured scaling script does not actually exist.

func (MissingScalingScript) Error

func (e MissingScalingScript) Error() string

type NoChangeRequired

type NoChangeRequired struct{}

NoChangeRequired is an error that is raised when the scaling script for a scaling script's group indicates that the group should not be scaled.

func (NoChangeRequired) Error

func (e NoChangeRequired) Error() string

type NoViableCandidates

type NoViableCandidates struct {
	Group     *Group
	Direction Direction
}

NoViableCandidates is an error that is raised when there are no servers in the desired state for the associated scaling event.

func (NoViableCandidates) Error

func (e NoViableCandidates) Error() string

type ScalingEvent

type ScalingEvent struct {
	GroupName   string
	Services    *Services
	Group       *Group
	Strategy    Strategy
	Direction   Direction
	Servers     []*Server
	Environment *Environment
	Candidates  []*Server
	Scaled      []*Server
	Failed      []*Server
	Error       error
}

ScalingEvent is a collection of data that acts as both input and output to a Scale transaction.

type ScalingFailure

type ScalingFailure struct {
	Group     *Group
	Direction Direction
	Scaled    []*Server
	Failed    []*Server
}

ScalingFailure is an error that is raised when an attempt to scale a group's scaling servers up or down fails.

func (ScalingFailure) Error

func (e ScalingFailure) Error() string

type ScalingScriptService

type ScalingScriptService interface {
	Exists(string) bool
}

ScalingScriptService is an interface that describes an object that knows how to interct with a ScalingScript.

type Server

type Server struct {
	ID            int
	ProvisionedID string
	State         string
	Hostname      string
	EnvironmentID string
}

Server is a representation of a server in an Engine Yard Cloud environment.

type ServerService

type ServerService interface {
	Get(string) (*Server, error)
	Start(*Server) error
	Stop(*Server) error
}

ServerService is an interface that describes an object that knows how to interact with a Server.

type Services

type Services struct {
	Groups       GroupService
	Servers      ServerService
	Environments EnvironmentService
	Scripts      ScalingScriptService
	Locker       LockService
	Runner       ExecService
	Log          LogService
}

Services is a handy collection of the various services one uses to perform tasks within Scaley.

type Severity

type Severity int

Severity describes the importance of a log message.

const (
	// Okay is used for success logs.
	Okay Severity = iota
	// Warning is used for information logs.
	Warning
	// Failure is used for failure logs.
	Failure
)

type Strategy

type Strategy int

Strategy describes one of several possible scaling strategies for a group.

const (
	// Legion is an all-or-nothing scaling strategy that acts upon all scaling
	// servers in a group.
	Legion Strategy = iota
	// Individual is a conservative strategy that acts upon only a single scaling
	// server in a group.
	Individual
)

func CalculateStrategy

func CalculateStrategy(group *Group) Strategy

CalculateStrategy takes a group and returns the strategy with which it is configured. If the group lacks a strategy, Legion is returned by default.

func (Strategy) String

func (s Strategy) String() string

type UnlockFailure

type UnlockFailure struct {
	Group *Group
}

UnlockFailure is an error that is raised when an attempt to unlock a group fails.

func (UnlockFailure) Error

func (e UnlockFailure) Error() string

type UnspecifiedScalingScript

type UnspecifiedScalingScript struct {
	Group *Group
}

UnspecifiedScalingScript is an error that is raised when a group does not have a scaling script configured.

func (UnspecifiedScalingScript) Error

func (e UnspecifiedScalingScript) Error() string

type UnspecifiedScalingServers

type UnspecifiedScalingServers struct {
	Group *Group
}

UnspecifiedScalingServers is an error that is raised when a group has no scaling servers configured.

func (UnspecifiedScalingServers) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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