engine

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EngineErrorDelay = 3 * time.Second

EngineErrorDelay is the amount of time the dependency engine waits between getting an error from a worker, and restarting it. It is exposed here so tests can make it smaller.

Functions

func APIManifold

func APIManifold(config APIManifoldConfig, start APIStartFunc) dependency.Manifold

APIManifold returns a dependency.Manifold that calls the supplied start func with the API resource defined in the config (once it's present).

func AgentAPIManifold

func AgentAPIManifold(config AgentAPIManifoldConfig, start AgentAPIStartFunc) dependency.Manifold

AgentAPIManifold returns a dependency.Manifold that calls the supplied start func with the API and agent resources defined in the config (once those resources are present).

func AgentManifold

func AgentManifold(config AgentManifoldConfig, start AgentStartFunc) dependency.Manifold

AgentManifold returns a dependency.Manifold that calls the supplied start func with the agent resource defined in the config (once it's present).

func DependencyEngineConfig

func DependencyEngineConfig() dependency.EngineConfig

DependencyEngineConfig returns a dependency engine config.

func FlagOutput

func FlagOutput(in worker.Worker, out interface{}) error

FlagOutput will expose, as a Flag, any worker that implements Flag.

func NewStaticFlagWorker

func NewStaticFlagWorker(value bool) worker.Worker

NewStaticFlagWorker returns a new Worker that implements Flag, whose Check method always returns the specified value.

func NewValueWorker

func NewValueWorker(value interface{}) (worker.Worker, error)

NewValueWorker returns a degenerate worker that exposes the supplied value when passed into ValueWorkerOutput. Please do not supply values that have their own dependency or lifecycle considerations; such values will subvert the operation of any containing dependency.Engine by insulating it from the failures and dependency changes of the contained value.

func ValueWorkerOutput

func ValueWorkerOutput(in worker.Worker, out interface{}) error

ValueWorkerOutput sets the value wrapped by the supplied valueWorker into the out pointer, if type-compatible, or fails.

Types

type APIManifoldConfig

type APIManifoldConfig struct {
	APICallerName string
}

Some (hopefully growing number of) manifolds completely depend on an API connection; this type configures them.

type APIStartFunc

type APIStartFunc func(base.APICaller) (worker.Worker, error)

APIStartFunc encapsulates the behaviour that varies among APIManifolds.

type AgentAPIManifoldConfig

type AgentAPIManifoldConfig struct {
	AgentName     string
	APICallerName string
}

Many manifolds completely depend on an agent and an API connection; this type configures them.

type AgentAPIStartFunc

type AgentAPIStartFunc func(agent.Agent, base.APICaller) (worker.Worker, error)

AgentAPIStartFunc encapsulates the behaviour that varies among AgentAPIManifolds.

type AgentManifoldConfig

type AgentManifoldConfig struct {
	AgentName string
}

Some manifolds just depend on an agent; this type configures them.

type AgentStartFunc

type AgentStartFunc func(agent.Agent) (worker.Worker, error)

AgentStartFunc encapsulates the behaviour that varies among AgentManifolds.

type Decorator

type Decorator interface {

	// Decorate returns a new Manifold, based on the one supplied.
	Decorate(dependency.Manifold) dependency.Manifold
}

Decorator creates copies of dependency.Manifolds with additional features.

type Flag

type Flag interface {

	// Check returns the flag's value. Check calls must *always* return
	// the same value for a given instantiation of the type implementing
	// Flag.
	Check() bool
}

Flag represents a single boolean used to determine whether a given manifold worker should run.

type Housing

type Housing struct {

	// Flags contains a list of names of Flag manifolds, such
	// that a decorated manifold will not start until all flags
	// are both present and valid (and will be stopped when that
	// is no longer true).
	Flags []string

	// Occupy is ignored if empty; otherwise it contains the name
	// of a fortress.Guest manifold, such that a decorated manifold
	// will never be run outside a Visit to that fortress.
	//
	// NOTE: this acquires a lock, and holds it for your manifold's
	// worker's whole lifetime. It's fine in isolation, but multiple
	// Occupy~s are almost certainly a Bad Idea.
	Occupy string

	// Filter is ignored if nil; otherwise it's unconditionally set
	// as the manifold's Filter. Similarly to Occupy, attempted use
	// of multiple filters is unlikely to be a great idea; it most
	// likely indicates that either your Engine's IsFatal is too
	// enthusiastic, or responsibility for termination is spread too
	// widely across your installed manifolds, or both.
	Filter dependency.FilterFunc
}

Housing is a Decorator that combines several common mechanisms for coordinating manifolds independently of their core concerns.

func (Housing) Decorate

func (housing Housing) Decorate(base dependency.Manifold) dependency.Manifold

Decorate is part of the Decorator interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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