domain

package
v0.0.0-...-ed56857 Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Local        = "local"
	DigitalOcean = "digitalocean"
	Linoid       = "linoid"
	Vultr        = "vultr"

	NodeStateNew        = NodeState(0)
	NodeStateActive     = NodeState(1)
	NodeStateUnhealthy  = NodeState(2)
	NodeStateTerminated = NodeState(4)
	NodeStateDeleted    = NodeState(8)

	ASGStateNew       = State(0)
	ASGStateActive    = State(1)
	ASGStateExecuting = State(2)
	ASGStateDeleted   = State(4)

	CMDStateNew        = CommandState(0)
	CMDStateInProgress = CommandState(1)
	CMDStateDone       = CommandState(2)
	CMDStateFailed     = CommandState(4)

	HealthMetricType MetricType = "health"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoScalingGroup

type AutoScalingGroup struct {
	ID       ID
	State    State
	Nodes    NodeSet
	Policies PolicySet
	Commands CommandSet
	// contains filtered or unexported fields
}

AutoScalingGroup ...

func NewAutoScalingGroup

func NewAutoScalingGroup(id ID) *AutoScalingGroup

NewAutoScalingGroup constructor

func (*AutoScalingGroup) AddMetrics

func (asg *AutoScalingGroup) AddMetrics(node ID, metrics MetricSeries) error

AddMetrics ...

func (*AutoScalingGroup) AddNode

func (asg *AutoScalingGroup) AddNode(node *Node) error

AddNode ...

func (*AutoScalingGroup) ChangePolicy

func (asg *AutoScalingGroup) ChangePolicy(policy Policy) error

ChangePolicy changes the policy, currently it overrides it and all state is lost

func (*AutoScalingGroup) Evaluate

func (asg *AutoScalingGroup) Evaluate() error

Evaluate goes through the policies and generates commands that needs to be executed

func (*AutoScalingGroup) Execute

func (asg *AutoScalingGroup) Execute() error

Execute required commands created by policies

func (*AutoScalingGroup) Remove

func (asg *AutoScalingGroup) Remove() error

Remove ...

func (*AutoScalingGroup) RemoveNode

func (asg *AutoScalingGroup) RemoveNode(node ID) error

RemoveNode ...

func (*AutoScalingGroup) Run

func (asg *AutoScalingGroup) Run() error

Run ASG and start monitoring nodes

func (*AutoScalingGroup) Setup

func (asg *AutoScalingGroup) Setup(nodes NodeSet, policies PolicySet) error

Setup ...

func (*AutoScalingGroup) Stop

func (asg *AutoScalingGroup) Stop() error

Stop ASG

type AutoScalingGroupSet

type AutoScalingGroupSet map[ID]*AutoScalingGroup

AutoScalingGroupSet type

func NewAutoScalingGroupSet

func NewAutoScalingGroupSet(asgs ...*AutoScalingGroup) AutoScalingGroupSet

NewAutoScalingGroupSet constructor

type BaseCommand

type BaseCommand struct {
	Provider Provider
	State    CommandState
	Error    *CMDError
	Timeout  time.Duration
}

type BaseCommands

type BaseCommands []BaseCommand

type CMDError

type CMDError struct {
	Code    int
	Message string
}

type Command

type Command interface {
	Execute(*AutoScalingGroup) error
}

type CommandSet

type CommandSet map[Order]Command

func NewCommandSet

func NewCommandSet(cmd ...Command) CommandSet

func (CommandSet) Merge

func (cs CommandSet) Merge(newSet CommandSet)

type CommandState

type CommandState int

type DesiredHealthyNodeAmountPerProviderPolicy

type DesiredHealthyNodeAmountPerProviderPolicy struct {
	ID                         ID
	Min, Max, Desired, Current int
	HealthyThreshold           float64
	CheckInterval              time.Duration
	Provider                   Provider
	ConsecutiveChecks          int
	ConsecutiveChecksNum       map[ID]int
}

DesiredNodeAmountPerProviderPolicy evaluates current state and creates Commands per provider

func (*DesiredHealthyNodeAmountPerProviderPolicy) Evaluate

Evaluate what commands should be executed by given ASG

func (*DesiredHealthyNodeAmountPerProviderPolicy) GetID

func (*DesiredHealthyNodeAmountPerProviderPolicy) Update

Update will reset checks state

type HealthMetric

type HealthMetric struct {
	Value float64
	Time  time.Time
}

HealthMetric metric

func (HealthMetric) GetTimestamp

func (hm HealthMetric) GetTimestamp() time.Time

GetTimestamp ...

func (HealthMetric) GetValue

func (hm HealthMetric) GetValue() float64

GetValue ...

type ID

type ID string

type Launch

type Launch struct {
	BaseCommand
}

func (*Launch) Execute

func (lc *Launch) Execute(asg *AutoScalingGroup) error

type LaunchLocal

type LaunchLocal struct {
	BaseCommand
}

func (*LaunchLocal) Execute

func (lc *LaunchLocal) Execute(asg *AutoScalingGroup) error

type Metric

type Metric interface {
	GetValue() float64
	GetTimestamp() time.Time
}

Metric type

func NewHealthMetric

func NewHealthMetric(val float64, t time.Time) Metric

NewHealthMetric constructor

type MetricSeries

type MetricSeries map[time.Time]Metric

MetricSeries type

func NewMetricSeries

func NewMetricSeries(m ...Metric) MetricSeries

NewHealthMetric constructor

type MetricType

type MetricType string

type MultiSupervisor

type MultiSupervisor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MultiSupervisor manages multiple ASG

func MakeMultiSupervisor

func MakeMultiSupervisor() *MultiSupervisor

MakeMultiSupervisor creates new supervisor that supports multiple ASG

func (*MultiSupervisor) Add

func (s *MultiSupervisor) Add(asg *AutoScalingGroup)

Add new ASG to run

func (*MultiSupervisor) Get

func (s *MultiSupervisor) Get(id ID) *AutoScalingGroup

Get ASG

func (*MultiSupervisor) Remove

func (s *MultiSupervisor) Remove(id ID)

Remove ASG

func (*MultiSupervisor) Run

func (s *MultiSupervisor) Run()

Run supervisor

type NIFaces

type NIFaces []NetworkInterface

type NetworkInterface

type NetworkInterface struct {
	ID ID
	IP net.IP
}

type Node

type Node struct {
	ID            ID
	Provider      Provider
	PrivateIface  NetworkInterface
	PublicIface   NetworkInterface
	State         NodeState
	Metrics       MetricSeries
	KeepMetricFor time.Duration
}

Node type

func NewNode

func NewNode() *Node

NewNode constructor

func (*Node) AddMetrics

func (n *Node) AddMetrics(metrics MetricSeries) error

AddMetrics ...

func (*Node) CalculateMetricValue

func (n *Node) CalculateMetricValue(metricType MetricType, from, to time.Time) float64

CalculateMetricValue calculates avg of requested metric

func (*Node) ChangeNetworkInterfaces

func (n *Node) ChangeNetworkInterfaces(prIface, puIface *NetworkInterface) error

ChangeNetworkInterfaces ...

func (*Node) ChangeState

func (n *Node) ChangeState(State NodeState) error

ChangeState ...

func (*Node) Remove

func (n *Node) Remove() error

Remove ...

func (*Node) Setup

func (n *Node) Setup(id ID, provider Provider, prIface, puIface NetworkInterface) error

Create new node

func (*Node) UpdateProvider

func (n *Node) UpdateProvider(provider Provider) error

ChangeProvider ...

type NodeSet

type NodeSet map[ID]*Node

NodeSet set

func NewNodeSet

func NewNodeSet(nodes ...*Node) NodeSet

NewNodeSet constructor

func (NodeSet) GetByID

func (ns NodeSet) GetByID(id ID) *Node

GetByID return node if found

type NodeState

type NodeState int

type Order

type Order int

type Policy

type Policy interface {
	// Evaluate takes in AutoScalingGroup and calculates what commands should be added or removed
	Evaluate(*AutoScalingGroup) error
	Update(Policy) error
	GetID() ID
}

Policy type

func NewDesiredNodeAmountPerProviderPolicy

func NewDesiredNodeAmountPerProviderPolicy(id ID, min, max, desired, consecutiveChecks int, healthyThreshold float64, checkInterval time.Duration, provider Provider) (Policy, error)

NewDesiredNodeAmountPerProviderPolicy constructor

type PolicySet

type PolicySet map[ID]Policy

Policies list

func NewPolicySet

func NewPolicySet(plc ...Policy) PolicySet

NewPolicySet constructor

func (PolicySet) Update

func (p PolicySet) Update(policy Policy) error

Update policy

type Provider

type Provider struct {
	ID     string
	Region string
	Size   string
	APIKey string
	Image  string
	SSHKey string
}

type Relaunch

type Relaunch struct {
	BaseCommand

	NodeID ID
}

func (*Relaunch) Execute

func (lc *Relaunch) Execute(asg *AutoScalingGroup) error

type RelaunchLocal

type RelaunchLocal struct {
	BaseCommand

	NodeID ID
}

func (*RelaunchLocal) Execute

func (lc *RelaunchLocal) Execute(asg *AutoScalingGroup) error

type State

type State int

type Terminate

type Terminate struct {
	BaseCommand

	NodeID ID
}

func (*Terminate) Execute

func (lc *Terminate) Execute(asg *AutoScalingGroup) error

type TerminateLocal

type TerminateLocal struct {
	BaseCommand

	NodeID ID
}

func (*TerminateLocal) Execute

func (lc *TerminateLocal) Execute(asg *AutoScalingGroup) error

type TokenSource

type TokenSource struct {
	AccessToken string
}

func (*TokenSource) Token

func (t *TokenSource) Token() (*oauth2.Token, error)

Jump to

Keyboard shortcuts

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