engine

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0 Imports: 8 Imported by: 21

Documentation

Overview

Package engine implements core engine of Aptomi, which does policy resolution (resolve), diff calculation between states (diff), and state enforcement by applying actions (apply).

Index

Constants

View Source
const (
	// RevisionStatusWaiting represents Revision status when it has been created, but apply haven't started yet
	RevisionStatusWaiting = "waiting"
	// RevisionStatusInProgress represents Revision status with apply in progress
	RevisionStatusInProgress = "inprogress"
	// RevisionStatusCompleted represents Revision status with apply finished
	RevisionStatusCompleted = "completed"
	// RevisionStatusError represents Revision status when a critical error happened (we should rarely see those)
	RevisionStatusError = "error"
)

Variables

View Source
var (
	// ActionObjects is a list of informational objects for all actions
	ActionObjects = []*runtime.Info{
		component.CreateActionObject,
		component.UpdateActionObject,
		component.DeleteActionObject,
		component.AttachClaimActionObject,
		component.DetachClaimActionObject,
		component.EndpointsActionObject,
	}

	// Objects is the list of informational objects for all objects in the engine
	Objects = runtime.AppendAll([]*runtime.Info{
		PolicyDataObject,
		RevisionObject,
		DesiredStateObject,
		resolve.ComponentInstanceObject,
	}, ActionObjects)
)
View Source
var DesiredStateObject = &runtime.Info{
	Kind:        "desired-state",
	Storable:    true,
	Versioned:   false,
	Constructor: func() runtime.Object { return &DesiredState{} },
}

DesiredStateObject is an informational data structure with Kind and Constructor for DesiredState

PolicyDataKey is the default key for the policy object (there is only one policy exists but with multiple generations)

View Source
var PolicyDataObject = &runtime.Info{
	Kind:        "policy",
	Storable:    true,
	Versioned:   true,
	Constructor: func() runtime.Object { return &PolicyData{} },
}

PolicyDataObject is an informational data structure with Kind and Constructor for PolicyData

RevisionKey is the default key for the Revision object (there is only one Revision exists but with multiple generations)

View Source
var RevisionObject = &runtime.Info{
	Kind:        "revision",
	Storable:    true,
	Versioned:   true,
	Constructor: func() runtime.Object { return &Revision{} },
}

RevisionObject is Info for Revision

Functions

func GetDesiredStateName added in v0.1.15

func GetDesiredStateName(revisionGen runtime.Generation) string

GetDesiredStateName returns name of the DesiredState for specific Revision generations

Types

type DesiredState added in v0.1.15

type DesiredState struct {
	runtime.TypeKind `yaml:",inline"`

	RevisionGen runtime.Generation
	Resolution  resolve.PolicyResolution
}

DesiredState represents snapshot of the state to be achieved by specific revision

func NewDesiredState added in v0.1.15

func NewDesiredState(revision *Revision, resolution *resolve.PolicyResolution) *DesiredState

NewDesiredState creates new DesiredState instance from revision and policy resolution

func (*DesiredState) GetName added in v0.1.15

func (ds *DesiredState) GetName() string

GetName returns name of the DesiredState

func (*DesiredState) GetNamespace added in v0.1.15

func (ds *DesiredState) GetNamespace() string

GetNamespace returns namespace of the DesiredState

type PolicyData

type PolicyData struct {
	runtime.TypeKind `yaml:",inline"`
	Metadata         PolicyDataMetadata

	// Objects stores all policy objects in map: namespace -> kind -> name -> generation
	Objects map[string]map[string]map[string]runtime.Generation
}

PolicyData is a struct which contains references to a generation for each object included into the policy

func (*PolicyData) Add

func (policyData *PolicyData) Add(obj lang.Base)

Add adds an object to PolicyData

func (*PolicyData) AsColumns added in v0.1.2

func (policyData *PolicyData) AsColumns() map[string]string

AsColumns returns PolicyData representation as columns

func (*PolicyData) GetDefaultColumns added in v0.1.2

func (policyData *PolicyData) GetDefaultColumns() []string

GetDefaultColumns returns default set of columns to be displayed

func (*PolicyData) GetGeneration

func (policyData *PolicyData) GetGeneration() runtime.Generation

GetGeneration returns PolicyData generation

func (*PolicyData) GetName

func (policyData *PolicyData) GetName() string

GetName returns PolicyData name

func (*PolicyData) GetNamespace

func (policyData *PolicyData) GetNamespace() string

GetNamespace returns PolicyData namespace

func (*PolicyData) Remove

func (policyData *PolicyData) Remove(obj lang.Base) bool

Remove deletes an object from PolicyData

func (*PolicyData) SetGeneration

func (policyData *PolicyData) SetGeneration(gen runtime.Generation)

SetGeneration sets PolicyData generation

type PolicyDataMetadata

type PolicyDataMetadata struct {
	Generation runtime.Generation
	UpdatedAt  time.Time
	UpdatedBy  string
}

PolicyDataMetadata is the metadata for PolicyData object that includes generation

type Revision

type Revision struct {
	runtime.TypeKind `yaml:",inline"`
	Metadata         runtime.GenerationMetadata

	// Policy to which this revision is attached to
	PolicyGen runtime.Generation

	Status         string
	CreatedAt      time.Time
	RecalculateAll bool

	Result    *action.ApplyResult
	AppliedAt time.Time

	// TODO: do not store apply log in revision
	ApplyLog []*event.APIEvent
}

Revision is a "milestone" in applying policy changes

func NewRevision added in v0.1.14

func NewRevision(gen runtime.Generation, policyGen runtime.Generation, recalculateAll bool) *Revision

NewRevision creates a new revision

func (*Revision) GetGeneration

func (revision *Revision) GetGeneration() runtime.Generation

GetGeneration returns Revision generation

func (*Revision) GetName

func (revision *Revision) GetName() string

GetName returns Revision name

func (*Revision) GetNamespace

func (revision *Revision) GetNamespace() string

GetNamespace returns Revision namespace

func (*Revision) SetGeneration

func (revision *Revision) SetGeneration(gen runtime.Generation)

SetGeneration returns Revision generation

Directories

Path Synopsis
Package actual defines a state updater, which reacts to changes in actual state done by engine applier.
Package actual defines a state updater, which reacts to changes in actual state done by engine applier.
Package apply implements state enforcer, which executes a list of actions to move from actual state to desired state, performing actual deployment of services and configuration of the underlying cloud components.
Package apply implements state enforcer, which executes a list of actions to move from actual state to desired state, performing actual deployment of services and configuration of the underlying cloud components.
action
Package action defines a base action (actions get born a result of policy diff calculation), as well as context which gets passed to all actions during apply phase.
Package action defines a base action (actions get born a result of policy diff calculation), as well as context which gets passed to all actions during apply phase.
action/component
Package component defines all component-specific actions, which get generated by the policy diff when component changes occur for specific component instances.
Package component defines all component-specific actions, which get generated by the policy diff when component changes occur for specific component instances.
Package diff allows Aptomi to determine the difference between actual state (running on the cloud) and desired state (that Aptomi wants to enforce), generating a list of actions to reconcile the difference.
Package diff allows Aptomi to determine the difference between actual state (running on the cloud) and desired state (that Aptomi wants to enforce), generating a list of actions to reconcile the difference.
Package progress implements progress indicators, which are used during state enforcement while running actions and plugins to estimate progress and show completion percentage to the user.
Package progress implements progress indicators, which are used during state enforcement while running actions and plugins to estimate progress and show completion percentage to the user.
Package resolve is a heart of Aptomi that performs policy resolution, taking policy and consumption claims as input, producing a set of components to be instantiated in the cloud (desired state) as output, along with their discovery parameters, code parameters, and component instance graph.
Package resolve is a heart of Aptomi that performs policy resolution, taking policy and consumption claims as input, producing a set of components to be instantiated in the cloud (desired state) as output, along with their discovery parameters, code parameters, and component instance graph.

Jump to

Keyboard shortcuts

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