operational_eval

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintGraph

func PrintGraph(g Graph)

func UpdateEdgeId

func UpdateEdgeId(e construct.SimpleEdge, oldId, newId construct.ResourceId) construct.SimpleEdge

Types

type EnqueueErrors

type EnqueueErrors map[Key]error

func (*EnqueueErrors) Append

func (e *EnqueueErrors) Append(key Key, err error)

func (EnqueueErrors) Error

func (e EnqueueErrors) Error() string

func (EnqueueErrors) Unwrap

func (e EnqueueErrors) Unwrap() []error

type Evaluator

type Evaluator struct {
	Solution solution.Solution
	// contains filtered or unexported fields
}

func NewEvaluator

func NewEvaluator(ctx solution.Solution) *Evaluator

func (*Evaluator) AddEdges

func (eval *Evaluator) AddEdges(es ...construct.Edge) error

func (*Evaluator) AddResources

func (eval *Evaluator) AddResources(rs ...*construct.Resource) error

func (*Evaluator) Evaluate

func (eval *Evaluator) Evaluate() error

func (*Evaluator) EvalutedOrder

func (eval *Evaluator) EvalutedOrder() [][]Key

func (*Evaluator) Log

func (eval *Evaluator) Log() *zap.SugaredLogger

func (*Evaluator) RecalculateUnevaluated

func (eval *Evaluator) RecalculateUnevaluated() error

RecalculateUnevaluated is used to recalculate the dependencies of all the unevaluated vertices in case some parts have "opened up" due to the evaluation of other vertices via template `{{ if }}` conditions or chained dependencies (eg `{{ fieldValue "X" (fieldValue "SomeRef" .Self) }}`, the dependency of X won't be able to be resolved until SomeRef is evaluated). There is likely a way to determine which vertices need to be recalculated, but the runtime impact of just recalculating them all isn't large at the size of graphs we're currently running with.

func (*Evaluator) RemoveEdge

func (eval *Evaluator) RemoveEdge(source, target construct.ResourceId) error

func (*Evaluator) RemoveResource

func (eval *Evaluator) RemoveResource(id construct.ResourceId) error

RemoveResource removes all edges from the resource. any property references (as [ResourceId] or [PropertyRef]) to the resource, and finally the resource itself.

func (*Evaluator) UpdateId

func (eval *Evaluator) UpdateId(oldId, newId construct.ResourceId) error

type Graph

type Graph graph.Graph[Key, Vertex]

type Key

type Key struct {
	Ref               construct.PropertyRef
	RuleHash          string
	Edge              construct.SimpleEdge
	GraphState        graphStateRepr
	PathSatisfication knowledgebase.EdgePathSatisfaction
}

func (Key) Less

func (key Key) Less(other Key) bool

func (Key) String

func (key Key) String() string

type ReadyPriority

type ReadyPriority int
const (
	// ReadyNow indicates the vertex is ready to be evaluated
	ReadyNow ReadyPriority = iota
	// NotReadyLow is used when it's relatively certain that the vertex will be ready, but cannot be 100% certain.
	NotReadyLow
	// NotReadyMid is for cases which don't clearly fit in [NotReadyLow] or [NotReadyHigh]
	NotReadyMid
	// NotReadyHigh is used for verticies which can almost never be 100% certain that they're correct based on the
	// current state.
	NotReadyHigh
	// NotReadyMax it reserved for when running the vertex would likely cause an error, rather than incorrect behaviour
	NotReadyMax
)

func (ReadyPriority) String

func (r ReadyPriority) String() string

type Vertex

type Vertex interface {
	Key() Key
	Evaluate(eval *Evaluator) error
	UpdateFrom(other Vertex)
	Dependencies(eval *Evaluator, propCtx dependencyCapturer) error
}

Jump to

Keyboard shortcuts

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