environ

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWaitAborted = errors.New("environ wait aborted")

ErrWaitAborted is returned from WaitForEnviron when the wait is terminated by closing the abort chan.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a Manifold that encapsulates a *Tracker and exposes it as an environs.Environ resource.

func WaitForEnviron

func WaitForEnviron(

	w watcher.NotifyWatcher,
	getter environs.EnvironConfigGetter,
	newEnviron environs.NewEnvironFunc,
	abort <-chan struct{},
) (environs.Environ, error)

WaitForEnviron waits for an valid environment to arrive from the given watcher. It terminates with ErrWaitAborted if it receives a value on abort.

In practice, it shouldn't wait at all: juju *should* never deliver invalid environ configs. Regardless, it should be considered deprecated; clients should prefer to access an Environ via a shared Tracker.

It never takes responsibility for the supplied watcher; the client remains responsible for detecting and handling any watcher errors that may occur, whether this func succeeds or fails.

Types

type Config

type Config struct {
	Observer       ConfigObserver
	NewEnvironFunc environs.NewEnvironFunc
}

Config describes the dependencies of a Tracker.

It's arguable that it should be called TrackerConfig, because of the heavy use of model config in this package.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be used to start a Tracker.

type ConfigObserver

type ConfigObserver interface {
	environs.EnvironConfigGetter
	WatchForModelConfigChanges() (watcher.NotifyWatcher, error)
	WatchCredential(tag names.CloudCredentialTag) (watcher.NotifyWatcher, error)
}

ConfigObserver exposes a model configuration and a watch constructor that allows clients to be informed of changes to the configuration.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName  string
	NewEnvironFunc environs.NewEnvironFunc
}

ManifoldConfig describes the resources used by a Tracker.

type Tracker

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

Tracker loads an environment, makes it available to clients, and updates the environment in response to config changes until it is killed.

func NewTracker

func NewTracker(config Config) (*Tracker, error)

NewTracker loads an environment from the observer and returns a new Tracker, or an error if anything goes wrong. If a tracker is returned, its Environ() method is immediately usable.

The caller is responsible for Kill()ing the returned Tracker and Wait()ing for any errors it might return.

func (*Tracker) Environ

func (t *Tracker) Environ() environs.Environ

Environ returns the encapsulated Environ. It will continue to be updated in the background for as long as the Tracker continues to run.

func (*Tracker) Kill

func (t *Tracker) Kill()

Kill is part of the worker.Worker interface.

func (*Tracker) Wait

func (t *Tracker) Wait() error

Wait is part of the worker.Worker interface.

Jump to

Keyboard shortcuts

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