core

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSpecs

func AllSpecs(specs []*types.Spec) []*types.Spec

AllSpecs returns a list of all the specs given plus any nested specs

func NormalizeSpecs

func NormalizeSpecs(uri string, input []byte) ([]*types.Spec, error)

NormalizeSpecs given the input bytes and its source, returns the normalized specs where template urls have been updated to be absolute and the specs are in dependency order.

func OrderByDependency

func OrderByDependency(specs []*types.Spec) ([]*types.Spec, error)

OrderByDependency returns the given specs in dependency order. The input is assume to be exhaustive in that all nested specs are part of the list.

func SpecsFromURL

func SpecsFromURL(uri string) (root string, config []byte, err error)

SpecsFromURL loads the raw specs from the URL and returns the root url and raw bytes

Types

type Addressable

type Addressable interface {
	// Kind corresponds to the packages under pkg/run/v0
	Kind() string
	// Plugin returns the address of the rpc (endpoint)
	Plugin() plugin.Name
	// Instance is the instance identifier
	Instance() string
	// String returns the string representation for debugging
	String() string
}

Addressable represents an object that can be reached / located, whether it's an RPC endpoint or an object within the rpc endpoint.

func AsAddressable

func AsAddressable(spec types.Spec) Addressable

AsAddressable returns a spec as an addressable object

func NewAddressable

func NewAddressable(kind string, pn plugin.Name, instance string) Addressable

NewAddressable returns a generic addressable object

func NewAddressableFromMetadata

func NewAddressableFromMetadata(kind string, metadata types.Metadata) Addressable

NewAddressableFromMetadata creates an addressable from metadata

func NewAddressableFromPluginMetadata

func NewAddressableFromPluginMetadata(meta plugin.Metadata) Addressable

NewAddressableFromPluginMetadata returns an Addressable from the plugin metadata

func NewAddressableFromPluginName

func NewAddressableFromPluginName(pn plugin.Name) Addressable

NewAddressableFromPluginName returns a generic addressable object from just the plugin name. The kind is assume to be the same as the lookup.

type Constructor

type Constructor func(spec types.Spec, properties *types.Any) (identity *types.Identity, state *types.Any, err error)

Constructor constructs the instance using the rendered input

type ConstructorError

type ConstructorError func(error, *types.Any, fsm.Instance) error

ConstructorError is the callback when the destruction succeeds

type ConstructorSuccess

type ConstructorSuccess func(*types.Object, fsm.Instance) error

ConstructorSuccess is the callback when construction succeeds

type Destructor

type Destructor func(*types.Object) error

Destructor destroys the instance

type ModelDefinition

type ModelDefinition func(*Process) (*fsm.Spec, error)

ModelDefinition defines the fsm model

type Objects

type Objects interface {
	FindBy(...interface{}) *types.Object
	Add(*types.Object)
	Remove(*types.Object)
	Len() int
}

Objects is a collection of instances instantiated from specs. They are queryable via the FindBy method

func NewObjects

func NewObjects(key func(*types.Object) []interface{}) Objects

NewObjects creates an index

type Process

type Process struct {
	ProcessDefinition

	Constructor fsm.Action
	// contains filtered or unexported fields
}

Process manages the lifecycle of one class of objects

func NewProcess

func NewProcess(model ModelDefinition,
	input ProcessDefinition,
	store Objects,
	plugins func() discovery.Plugins) (*Process, error)

NewProcess creates a new process to manage a spec and the lifecycle of its instances.

func (*Process) Instance

func (p *Process) Instance(object *types.Object) fsm.Instance

Instance returns an fsm instance given the Object reference

func (*Process) Instances

func (p *Process) Instances() *fsm.Set

Instances returns a collection of fsm instances

func (*Process) NewInstance

func (p *Process) NewInstance(initialState fsm.Index) (fsm.Instance, error)

NewInstance creates an instance of the object in the initial state, calling the process constructor

func (*Process) Object

func (p *Process) Object(instance fsm.Instance) *types.Object

Object returns the Object reference given an instance

func (*Process) Start

func (p *Process) Start(clock *fsm.Clock) error

Start starts the management process of the instances

type ProcessDefinition

type ProcessDefinition struct {
	Spec               *types.Spec
	Constructor        Constructor
	ConstructorError   ConstructorError
	ConstructorSuccess ConstructorSuccess
	Destructor         Destructor
}

ProcessDefinition has the Spec and the actual behaviors like construct/ destruct

Jump to

Keyboard shortcuts

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