Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cluster ¶
type Cluster struct {
ID ClusterID
Config ConfigID
Name string
MinSize int
MaxSize int
Instances []Instance
}
Cluster carries attributes of a cluster that are needed to run the cycling algorithm.
type Environment ¶
type Environment interface {
// LookupClusterID takes a cluster name as argument, returns the matching
// cluster ID.
LookupClusterID(context.Context, string) (ClusterID, error)
// DescribeCluster returns the full cluster information for the cluster
// identified by the given ID.
DescribeCluster(context.Context, ClusterID) (Cluster, error)
// StartInstances stats count instances in the cluster identified by the
// given ID, returns instance values representing the newly created
// instances.
StartInstances(context.Context, ClusterID, int) error
// DrainInstances puts the instances identified by the given IDs in draining
// state.
DrainInstances(context.Context, ...InstanceID) error
// TerminateInstances terminates the instance identified by the given IDs.
TerminateInstances(context.Context, ...InstanceID) error
// WaitInstances is called when the cluster cycling algorithm is waiting
// for a given instances to enter a specific state.
WaitInstances(context.Context, InstanceState, ...InstanceID) error
}
The Environment interface abstracts the environment that controls the actual instance clusters that are to be cycled.
Implementations of the Environment interface must be safe to use concurrently from multiple goroutines.
func DryRun ¶
func DryRun(env Environment) Environment
DryRun is an Environment decorator which only enables read-only operations on env.
type Instance ¶
type Instance struct {
ID InstanceID
State InstanceState
Config ConfigID
CreatedAt time.Time
UpdatedAt time.Time
}
Instance carries attributes of an instance that are needed to run the cycling algorithm.
type InstanceState ¶
type InstanceState string
InstsanceState is an enumeration type representing the various states that instances may be in.
const ( Starting InstanceState = "starting" Started InstanceState = "started" Draining InstanceState = "draining" Drained InstanceState = "drained" Terminating InstanceState = "terminating" Terminated InstanceState = "terminated" // impossible )
type Task ¶
type Task interface {
Run(ctx context.Context, env Environment) error
}
The Task interface abstracts the execution of a single operation on an environment.
Programs typically generate tasks by calling the Tasks function and passing configuration and constraints to determine what operations can be executed.
func Tasks ¶
func Tasks(cluster Cluster, config TaskConfig) ([]Task, error)
Tasks generates a list of tasks that represents the next steps that can be taken to cycle the given cluster, using the config value to apply constraints on the operations.
The function returns an empty list of tasks if there is no more work left to be done to cycle the cluster.
type TaskConfig ¶
type TaskConfig struct {
// The final desired size of the cluster.
TargetSize int
// The minimum instance count in the cluster.
MinSize int
// The maximum instance count in the cluster.
MaxSize int
// The time limit on how long instances may take to drain.
DrainTimeout time.Duration
}
TaskConfig is a configuration object used to generate a list of tasks to be executed when calling the Tasks function.