Documentation ¶
Index ¶
- Variables
- func GetInstanceRange(min, max int, getInstance func(int) (*gce.Instance, error)) ([]*gce.Instance, error)
- func GetInstanceSet(intSet string, getInstance func(int) *gce.Instance) ([]*gce.Instance, error)
- type Autoscaler
- func (a *Autoscaler) GetInstanceStatuses() map[string]bool
- func (a *Autoscaler) GetNamesOfManagedInstances() []string
- func (a *Autoscaler) GetOnlineInstances() []string
- func (a *Autoscaler) Start(instanceNames []string) error
- func (a *Autoscaler) StartAllInstances() error
- func (a *Autoscaler) Stop(instanceNames []string) error
- func (a *Autoscaler) StopAllInstances() error
- func (a *Autoscaler) Update() error
- type IAutoscaler
- type MockAutoscaler
- func (m *MockAutoscaler) GetInstanceStatuses() map[string]bool
- func (m *MockAutoscaler) GetNamesOfManagedInstances() []string
- func (m *MockAutoscaler) GetOnlineInstances() []string
- func (m *MockAutoscaler) Start([]string) error
- func (m *MockAutoscaler) StartAllInstances() error
- func (m *MockAutoscaler) Stop([]string) error
- func (m *MockAutoscaler) StopAllInstances() error
- func (m *MockAutoscaler) Update() error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
TestInstances = []string{"ct-gce-001", "ct-gce-002"}
)
Functions ¶
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 string, ts oauth2.TokenSource, instances []*gce.Instance) (*Autoscaler, error)
NewAutoscaler returns an Autoscaler instance which manages the given GCE instances. Automatically calls Update().
func (*Autoscaler) GetInstanceStatuses ¶
func (a *Autoscaler) GetInstanceStatuses() map[string]bool
See documentation for IAutoscaler.
func (*Autoscaler) GetNamesOfManagedInstances ¶
func (a *Autoscaler) GetNamesOfManagedInstances() []string
See documentation for IAutoscaler.
func (*Autoscaler) GetOnlineInstances ¶
func (a *Autoscaler) GetOnlineInstances() []string
See documentation for IAutoscaler.
func (*Autoscaler) Start ¶
func (a *Autoscaler) Start(instanceNames []string) error
See documentation for IAutoscaler.
func (*Autoscaler) StartAllInstances ¶
func (a *Autoscaler) StartAllInstances() error
See documentation for IAutoscaler.
func (*Autoscaler) Stop ¶
func (a *Autoscaler) Stop(instanceNames []string) error
See documentation for IAutoscaler.
func (*Autoscaler) StopAllInstances ¶
func (a *Autoscaler) StopAllInstances() error
See documentation for IAutoscaler.
type IAutoscaler ¶
type IAutoscaler interface { // GetInstanceStatuses returns a map of instance names to booleans // indicating whether each instance is online as of the last Update(). GetInstanceStatuses() map[string]bool // GetNamesOfManagedInstances returns names of all instances managed by // this autoscaler. GetNamesOfManagedInstances() []string // GetOnlineInstances returns a slice of all online instance names as of // the last Update(). GetOnlineInstances() []string // Start the given instances. // Note: This method returns when all instances are in RUNNING state. // Does not check to see if they are ready (ssh-able). Start([]string) 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). StartAllInstances() error // Stop the given instances. Stop([]string) error // StopAllInstances stops all instances. StopAllInstances() error // Update determines which instances are online and caches that // information. Update() error }
Interface useful for mocking. TODO(borenet): This doesn't really "auto" scale anything.
type MockAutoscaler ¶
func (*MockAutoscaler) GetInstanceStatuses ¶
func (m *MockAutoscaler) GetInstanceStatuses() map[string]bool
func (*MockAutoscaler) GetNamesOfManagedInstances ¶
func (m *MockAutoscaler) GetNamesOfManagedInstances() []string
func (*MockAutoscaler) GetOnlineInstances ¶
func (m *MockAutoscaler) GetOnlineInstances() []string
func (*MockAutoscaler) Start ¶
func (m *MockAutoscaler) Start([]string) error
func (*MockAutoscaler) StartAllInstances ¶
func (m *MockAutoscaler) StartAllInstances() error
func (*MockAutoscaler) Stop ¶
func (m *MockAutoscaler) Stop([]string) error
func (*MockAutoscaler) StopAllInstances ¶
func (m *MockAutoscaler) StopAllInstances() error
func (*MockAutoscaler) Update ¶
func (m *MockAutoscaler) Update() error
Click to show internal directories.
Click to hide internal directories.