Back to godoc.org

Package state

v0.0.0-...-5fa6b02
Latest Go to latest

The latest major version is .

Published: today | License: AGPL-3.0 | Module: github.com/juju/juju

Index

Variables

var ErrStateClosed = errors.New("state closed")

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a manifold whose worker which wraps a *state.State, which is in turn wrapper by a StateTracker. It will exit if the State's associated mongodb session dies.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName              string
	StateConfigWatcherName string
	OpenStatePool          func(coreagent.Config) (*state.StatePool, error)
	PingInterval           time.Duration

	// SetStatePool is called with the state pool when it is created,
	// and called again with nil just before the state pool is closed.
	// This is used for publishing the state pool to the agent's
	// introspection worker, which runs outside of the dependency
	// engine; hence the manifold's Output cannot be relied upon.
	SetStatePool func(*state.StatePool)
}

ManifoldConfig provides the dependencies for Manifold.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type StateTracker

type StateTracker interface {
	// Use returns the wrapped StatePool, recording the use of
	// it. ErrStateClosed is returned if the StatePool is closed.
	Use() (*state.StatePool, error)

	// Done records that there's one less user of the wrapped StatePool,
	// closing it if there's no more users. ErrStateClosed is returned
	// if the StatePool has already been closed (indicating that Done has
	// called too many times).
	Done() error

	// Report is used to give details about what is going on with this state tracker.
	Report() map[string]interface{}
}

StateTracker describes a type which wraps and manages the lifetime of a *state.State and associated *state.StatePool.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier