state

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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.

Types

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.

Jump to

Keyboard shortcuts

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