circuitfactory

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DOTGraph added in v1.1.0

func DOTGraph(graph *policymonitoringv1.Graph) string

DOTGraph returns Components and Links as a DOT graph description.

func DecodePortMap added in v0.21.0

func DecodePortMap(config any, circuitID string) (runtime.PortToSignals, error)

DecodePortMap decodes a proto port map into a PortToSignals map.

func FactoryModule

func FactoryModule() fx.Option

FactoryModule for component factory run via the main app.

func FactoryModuleForPolicyApp

func FactoryModuleForPolicyApp(circuitAPI runtime.CircuitAPI) fx.Option

FactoryModuleForPolicyApp for component factory run via the policy app. For singletons in the Policy scope.

func MermaidGraph added in v1.1.0

func MermaidGraph(graph *policymonitoringv1.Graph) string

MermaidGraph returns Components and Links as a mermaid graph.

func Module

func Module() fx.Option

Module for circuit and component factory run via the main app.

Types

type Circuit

type Circuit struct {
	Tree           Tree
	LeafComponents []*runtime.ConfiguredComponent
}

Circuit is a compiled Circuit

Circuit can also be converted to its graph view.

func CompileFromProto

func CompileFromProto(
	policyProto *policylangv1.Policy,
	policyReadAPI iface.Policy,
) (*Circuit, fx.Option, error)

CompileFromProto compiles a protobuf circuit definition into a Circuit.

This is helper for CreateComponents + runtime.Compile.

func (*Circuit) CircuitView added in v1.1.0

func (circuit *Circuit) CircuitView() (*policymonitoringv1.CircuitView, error)

CircuitView returns a CircuitView of the circuit.

func (*Circuit) Components

func (circuit *Circuit) Components() []*runtime.ConfiguredComponent

Components returns a list of CompiledComponents, ready to create runtime.Circuit.

type Tree added in v0.21.0

type Tree struct {
	Node     *runtime.ConfiguredComponent
	Children []Tree
}

Tree is a graph view of a Circuit.

func NewComponentAndOptions

func NewComponentAndOptions(
	componentProto *policylangv1.Component,
	componentID runtime.ComponentID,
	policyReadAPI iface.Policy,
) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)

NewComponentAndOptions creates parent and leaf components and their fx options for a component spec.

func ParseNestedCircuit added in v0.21.0

func ParseNestedCircuit(
	nestedCircuitID runtime.ComponentID,
	nestedCircuit *policylangv1.NestedCircuit,
	policyReadAPI iface.Policy,
) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)

ParseNestedCircuit parses a nested circuit and returns the parent, leaf components, and options.

func RootTree added in v1.1.0

func RootTree(circuitProto *policylangv1.Circuit) (Tree, error)

RootTree returns Tree to represent Circuit root.

func (*Tree) CreateComponents added in v1.1.0

func (tree *Tree) CreateComponents(
	componentsProto []*policylangv1.Component,
	circuitID runtime.ComponentID,
	policyReadAPI iface.Policy,
) ([]*runtime.ConfiguredComponent, fx.Option, error)

CreateComponents creates circuit components along with their identifiers and fx options.

Note that number of returned components might be greater than number of components in componentsProto, as some components may be composite multi-component stacks or nested circuits.

func (*Tree) ExpandCircuit added in v1.1.0

func (tree *Tree) ExpandCircuit(depth int) []*runtime.ConfiguredComponent

ExpandCircuit returns a list of ConfiguredComponents in the circuit expanded up to given depth.

func (*Tree) ExpandSubCircuit added in v1.1.0

func (tree *Tree) ExpandSubCircuit(componentID runtime.ComponentID, depth int) ([]*runtime.ConfiguredComponent, []*runtime.ConfiguredComponent, error)

ExpandSubCircuit returns a list of ConfiguredComponents in the circuit with the component at componentID expanded up to given depth.

func (*Tree) GetSubGraph added in v1.1.0

func (tree *Tree) GetSubGraph(componentID runtime.ComponentID, depth int) (*policymonitoringv1.Graph, error)

GetSubGraph returns a subgraph of the tree.

func (*Tree) TreeGraph added in v1.1.0

func (tree *Tree) TreeGraph() (*policymonitoringv1.Tree, error)

TreeGraph walks the tree and gets graph representation of the links amongst the children of each node.

Jump to

Keyboard shortcuts

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