Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ShortPoll        = 3 * time.Second
	ShortPollBackoff = 2.0
	ShortPollCap     = 1 * time.Minute
	LongPoll         = 15 * time.Minute
)

ShortPoll and LongPoll hold the polling intervals for the instance updater. When a machine has no address or is not started, it will be polled at ShortPoll intervals until it does, exponentially backing off with an exponent of ShortPollBackoff until a maximum of ShortPollCap is reached.

When a machine has an address and is started LongPoll will be used to check that the instance address or status has not changed.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a Manifold that encapsulates the instancepoller worker.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

NewWorker returns a worker that keeps track of the machines in the state and polls their instance addresses and status periodically to keep them up to date.

Types

type Config

type Config struct {
	Clock   clock.Clock
	Facade  FacadeAPI
	Environ Environ
	Logger  Logger

	CredentialAPI common.CredentialAPI
}

Config encapsulates the configuration options for instantiating a new instance poller worker.

func (Config) Validate

func (config Config) Validate() error

Validate checks whether the worker configuration settings are valid.

type Environ

type Environ interface {
	Instances(ctx context.ProviderCallContext, ids []instance.Id) ([]instances.Instance, error)
	NetworkInterfaces(ctx context.ProviderCallContext, ids []instance.Id) ([]network.InterfaceInfos, error)
}

Environ specifies the provider-specific methods needed by the instance poller.

type FacadeAPI

type FacadeAPI interface {
	WatchModelMachines() (watcher.StringsWatcher, error)
	Machine(tag names.MachineTag) (Machine, error)
}

FacadeAPI specifies the api-server methods needed by the instance poller.

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger represents the methods used by the worker to log details.

type Machine

type Machine interface {
	Id() string
	InstanceId() (instance.Id, error)
	SetProviderNetworkConfig(network.InterfaceInfos) (network.ProviderAddresses, bool, error)
	InstanceStatus() (params.StatusResult, error)
	SetInstanceStatus(status.Status, string, map[string]interface{}) error
	String() string
	Refresh() error
	Status() (params.StatusResult, error)
	Life() life.Value
	IsManual() (bool, error)
}

Machine specifies an interface for machine instances processed by the instance poller.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	ClockName     string
	EnvironName   string
	Logger        Logger

	NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}

ManifoldConfig describes the resources used by the instancepoller worker.

Directories

Path Synopsis
mocks Package mocks is a generated GoMock package.