engine

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataflowView View = "dataflow"
	IACView      View = "iac"

	ParentIconTag Tag = "parent"
	BigIconTag    Tag = "big"
	SmallIconTag  Tag = "small"
	NoRenderTag   Tag = "no-render"
)

Variables

This section is empty.

Functions

func ApplyConstraints

func ApplyConstraints(sol solution.Solution) error

func GraphToDOT

func GraphToDOT(kb knowledgebase.TemplateKB, g construct.Graph, out io.Writer) error

func GraphToSVG

func GraphToSVG(kb knowledgebase.TemplateKB, g construct.Graph, prefix string) error

func NewSolution

func NewSolution(ctx context.Context, kb knowledgebase.TemplateKB, globalTag string, constraints *constraints.Constraints) *engineSolution

Types

type Engine

type Engine struct {
	Kb knowledgebase.TemplateKB
}

Engine is a struct that represents the object which processes the resource graph and applies constraints

func NewEngine

func NewEngine(kb knowledgebase.TemplateKB) *Engine

func (*Engine) EdgeCanBeExpanded

func (e *Engine) EdgeCanBeExpanded(sol *engineSolution, source construct.ResourceId, target construct.ResourceId) (result bool, cacheable bool, err error)

EdgeCanBeExpanded returns true if there is a set of kb paths between the source and target that satisfies path satisfaction classifications for both the source and target.

This is used to determine (on a best-effort basis) if an edge can be expanded without fully solving the graph (which is expensive).

func (*Engine) GetValidEdgeTargets

func (e *Engine) GetValidEdgeTargets(req *GetPossibleEdgesContext) (map[string][]string, error)

GetValidEdgeTargets returns a map of valid edge targets for each source resource in the supplied graph. The returned map is keyed by the source resource's string representation. The value for each source resource is a list of valid target resources.

Targets are considered valid if there is a set of kb paths between the source and target that satisfies both source and target path satisfaction classifications.

A partial set of valid targets can be generated using the filter criteria in the context's config.

func (*Engine) GetViewsDag

func (e *Engine) GetViewsDag(view View, sol solution.Solution) (visualizer.VisGraph, error)

func (*Engine) ListAttributes

func (e *Engine) ListAttributes() []string

func (*Engine) ListFunctionalities

func (e *Engine) ListFunctionalities() []knowledgebase.Functionality

func (*Engine) ListProviders

func (e *Engine) ListProviders() []string

func (*Engine) ListResources

func (e *Engine) ListResources() []construct.ResourceId

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, req *SolveRequest) (solution.Solution, error)

func (*Engine) VisualizeViews

func (e *Engine) VisualizeViews(ctx solution.Solution) ([]klotho_io.File, error)

type EngineMain

type EngineMain struct {
	Engine *Engine
	// contains filtered or unexported fields
}

func (*EngineMain) AddEngine

func (em *EngineMain) AddEngine() error

func (*EngineMain) AddEngineCli

func (em *EngineMain) AddEngineCli(root *cobra.Command)

func (*EngineMain) GetValidEdgeTargets

func (em *EngineMain) GetValidEdgeTargets(cmd *cobra.Command, args []string) error

func (*EngineMain) ListAttributes

func (em *EngineMain) ListAttributes(cmd *cobra.Command, args []string) error

func (*EngineMain) ListResourceTypes

func (em *EngineMain) ListResourceTypes(cmd *cobra.Command, args []string) error

func (*EngineMain) Run

func (*EngineMain) RunEngine

func (em *EngineMain) RunEngine(cmd *cobra.Command, args []string) (exitCode int)

type FileFormat

type FileFormat struct {
	Constraints constraints.Constraints
	Graph       construct.Graph
}

FileFormat is used for engine input/output to render or read a YAML file An example yaml file is:

constraints:
    - scope: application
      operator: add
      node: p:t:a
resources:
    p:t:a:
    p:t:b:
edges:
    p:t:a -> p:t:b:

func (FileFormat) MarshalYAML

func (ff FileFormat) MarshalYAML() (interface{}, error)

func (*FileFormat) UnmarshalYAML

func (ff *FileFormat) UnmarshalYAML(node *yaml.Node) error

type GetPossibleEdgesContext

type GetPossibleEdgesContext struct {
	InputGraph []byte
	GetValidEdgeTargetsConfig
}

type GetValidEdgeTargetsConfig

type GetValidEdgeTargetsConfig struct {
	Resources struct {
		Sources []construct.ResourceId
		Targets []construct.ResourceId
	}
	ResourceTypes struct {
		Sources []construct.ResourceId
		Targets []construct.ResourceId
	}
	Tags []Tag
}

func ReadGetValidEdgeTargetsConfig

func ReadGetValidEdgeTargetsConfig(path string) (GetValidEdgeTargetsConfig, error)

type MakeOperationalView

type MakeOperationalView engineSolution

func (*MakeOperationalView) AddEdge

func (view *MakeOperationalView) AddEdge(source, target construct.ResourceId, options ...func(*graph.EdgeProperties)) (err error)

func (*MakeOperationalView) AddEdgesFrom

func (view *MakeOperationalView) AddEdgesFrom(g construct.Graph) error

func (*MakeOperationalView) AddVertex

func (view *MakeOperationalView) AddVertex(value *construct.Resource, options ...func(*graph.VertexProperties)) error

func (*MakeOperationalView) AddVerticesFrom

func (view *MakeOperationalView) AddVerticesFrom(g construct.Graph) error

func (*MakeOperationalView) AdjacencyMap

func (*MakeOperationalView) Clone

func (view *MakeOperationalView) Clone() (construct.Graph, error)

func (*MakeOperationalView) Edge

func (view *MakeOperationalView) Edge(source, target construct.ResourceId) (construct.ResourceEdge, error)

func (*MakeOperationalView) Edges

func (view *MakeOperationalView) Edges() ([]construct.Edge, error)

func (*MakeOperationalView) MakeEdgesOperational

func (view *MakeOperationalView) MakeEdgesOperational(edges []construct.Edge) error

func (*MakeOperationalView) MakeResourcesOperational

func (view *MakeOperationalView) MakeResourcesOperational(resources []*construct.Resource) error

func (*MakeOperationalView) Order

func (view *MakeOperationalView) Order() (int, error)

func (*MakeOperationalView) PredecessorMap

func (view *MakeOperationalView) PredecessorMap() (map[construct.ResourceId]map[construct.ResourceId]construct.Edge, error)

func (*MakeOperationalView) RemoveEdge

func (view *MakeOperationalView) RemoveEdge(source, target construct.ResourceId) error

func (*MakeOperationalView) RemoveVertex

func (view *MakeOperationalView) RemoveVertex(hash construct.ResourceId) error

func (*MakeOperationalView) Size

func (view *MakeOperationalView) Size() (int, error)

func (*MakeOperationalView) Traits

func (view *MakeOperationalView) Traits() *graph.Traits

func (*MakeOperationalView) UpdateEdge

func (view *MakeOperationalView) UpdateEdge(source, target construct.ResourceId, options ...func(properties *graph.EdgeProperties)) error

func (*MakeOperationalView) UpdateResourceID

func (view *MakeOperationalView) UpdateResourceID(oldId, newId construct.ResourceId) error

func (*MakeOperationalView) Vertex

func (*MakeOperationalView) VertexWithProperties

func (view *MakeOperationalView) VertexWithProperties(hash construct.ResourceId) (*construct.Resource, graph.VertexProperties, error)

type SolveRequest

type SolveRequest struct {
	Constraints  constraints.Constraints
	InitialState construct.Graph
	GlobalTag    string
}

SolveRequest is a struct that represents the context of the engine The context is used to store the state of the engine

func (SolveRequest) MarshalYAML

func (req SolveRequest) MarshalYAML() (interface{}, error)

type Tag

type Tag string

func GetResourceVizTag

func GetResourceVizTag(kb knowledgebase.TemplateKB, view View, resource construct.ResourceId) Tag

type View

type View string

Jump to

Keyboard shortcuts

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