autoscaler

package
v0.0.0-...-03d6fc4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestInstances = []string{"ct-gce-001", "ct-gce-002"}
)

Functions

This section is empty.

Types

type Autoscaler

type Autoscaler struct {
	// contains filtered or unexported fields
}

Autoscaler is a struct used for autoscaling instances in GCE.

func NewAutoscaler

func NewAutoscaler(projectId, zone, workdir string, minInstanceNum, maxInstanceNum int, getInstance func(int) *gce.Instance) (*Autoscaler, error)

NewAutoscaler returns an Autoscaler instance.

func (*Autoscaler) GetNamesOfManagedInstances

func (a *Autoscaler) GetNamesOfManagedInstances() []string

GetNamesOfManagedInstances returns names of all instances managed by this autoscaler.

func (*Autoscaler) GetRunningInstances

func (a *Autoscaler) GetRunningInstances() ([]string, error)

GetRunningInstances returns a slice of all running instance names.

func (*Autoscaler) StartAllInstances

func (a *Autoscaler) StartAllInstances() error

StartAllInstances starts all instances. Note: This method returns when all instances are in RUNNING state. Does not check to see if they are ready (ssh-able).

func (*Autoscaler) StopAllInstances

func (a *Autoscaler) StopAllInstances() error

StopAllInstances stops all instances.

type IAutoscaler

type IAutoscaler interface {
	GetRunningInstances() ([]string, error)
	GetNamesOfManagedInstances() []string
	StopAllInstances() error
	StartAllInstances() error
}

Interface useful for mocking.

type MockAutoscaler

type MockAutoscaler struct {
	StopAllInstancesTimesCalled  int
	StartAllInstancesTimesCalled int
}

func (*MockAutoscaler) GetNamesOfManagedInstances

func (m *MockAutoscaler) GetNamesOfManagedInstances() []string

func (*MockAutoscaler) GetRunningInstances

func (m *MockAutoscaler) GetRunningInstances() ([]string, error)

func (*MockAutoscaler) StartAllInstances

func (m *MockAutoscaler) StartAllInstances() error

func (*MockAutoscaler) StopAllInstances

func (m *MockAutoscaler) StopAllInstances() error

Jump to

Keyboard shortcuts

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