Documentation ¶
Index ¶
- func ConvertOldComponentToNew(oldComponentProto proto.Message, newComponentProto proto.Message, ...) error
- func DOTGraph(graph *policymonitoringv1.Graph) string
- func DecodePortMap(config any, circuitID string) (runtime.PortToSignals, error)
- func FactoryModule() fx.Option
- func FactoryModuleForPolicyApp(circuitAPI runtime.CircuitSuperAPI) fx.Option
- func MermaidGraph(graph *policymonitoringv1.Graph) string
- func Module() fx.Option
- type Circuit
- type Tree
- func CreateComponents(componentsProto []*policylangv1.Component, circuitID runtime.ComponentID, ...) ([]Tree, []*runtime.ConfiguredComponent, fx.Option, error)
- func NewComponentAndOptions(componentProto *policylangv1.Component, componentID runtime.ComponentID, ...) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)
- func NewNestedCircuitAndOptions(nestedCircuit *policylangv1.NestedCircuit, nestedCircuitID runtime.ComponentID, ...) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)
- func NewTree(Node *runtime.ConfiguredComponent, Children []Tree) Tree
- func ParseNestedCircuit(configuredComponent *runtime.ConfiguredComponent, ...) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)
- func RootTree(circuitProto *policylangv1.Circuit) (Tree, error)
- func (tree *Tree) ExpandCircuit(depth int) []*runtime.ConfiguredComponent
- func (tree *Tree) ExpandSubCircuit(componentID runtime.ComponentID, depth int) ([]*runtime.ConfiguredComponent, []*runtime.ConfiguredComponent, error)
- func (tree *Tree) GetSubGraph(componentID runtime.ComponentID, depth int) (*policymonitoringv1.Graph, error)
- func (tree *Tree) TreeGraph() (*policymonitoringv1.Tree, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertOldComponentToNew ¶
func ConvertOldComponentToNew(oldComponentProto proto.Message, newComponentProto proto.Message, fieldMappings map[string]string) error
ConvertOldComponentToNew converts an old component protobuf message to a new component protobuf message using the provided field mappings. It takes in the oldComponentProto, newComponentProto, and fieldMappings as parameters. Param: oldComponentProto is the protobuf message that needs to be converted to the new format. Param: newComponentProto is the protobuf message that will be populated with the converted data. Param: fieldMappings is a map of old field names to new field names. Example format:
{ "A_field": "Y_field", "A_field.B_field": "Z_field", "C_field.D_field": "G_field", "C_field.D_field.E_field": "H_field", }
In this example, the following renames will be performed: 1. A_field -> Y_field 2. A_field.B_field -> Y_field.Z_field 3. C_field.D_field -> C_field.G_field 4. C_field.D_field.E_field -> C_field.G_field.H_field The function returns an error if there is an issue with marshaling or unmarshaling the protobuf messages or JSON data.
func DOTGraph ¶
func DOTGraph(graph *policymonitoringv1.Graph) string
DOTGraph returns Components and Links as a DOT graph description.
func DecodePortMap ¶
func DecodePortMap(config any, circuitID string) (runtime.PortToSignals, error)
DecodePortMap decodes a proto port map into a PortToSignals map.
func FactoryModule ¶
FactoryModule for component factory run via the main app.
func FactoryModuleForPolicyApp ¶
func FactoryModuleForPolicyApp(circuitAPI runtime.CircuitSuperAPI) fx.Option
FactoryModuleForPolicyApp for component factory run via the policy app. For singletons in the Policy scope.
func MermaidGraph ¶
func MermaidGraph(graph *policymonitoringv1.Graph) string
MermaidGraph returns Components and Links as a mermaid graph.
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 ¶
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 ¶
type Tree struct { Node *runtime.ConfiguredComponent Children []Tree }
Tree is a graph view of a Circuit.
func CreateComponents ¶ added in v2.11.0
func CreateComponents( componentsProto []*policylangv1.Component, circuitID runtime.ComponentID, policyReadAPI iface.Policy, ) ([]Tree, []*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 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 NewNestedCircuitAndOptions ¶ added in v2.11.0
func NewNestedCircuitAndOptions( nestedCircuit *policylangv1.NestedCircuit, nestedCircuitID runtime.ComponentID, policyReadAPI iface.Policy, ) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)
NewNestedCircuitAndOptions parses a nested circuit and returns the parent, leaf components, and options.
func NewTree ¶ added in v2.11.0
func NewTree(Node *runtime.ConfiguredComponent, Children []Tree) Tree
NewTree creates a new Tree.
func ParseNestedCircuit ¶
func ParseNestedCircuit( configuredComponent *runtime.ConfiguredComponent, nestedCircuit *policylangv1.NestedCircuit, nestedCircuitID runtime.ComponentID, policyReadAPI iface.Policy, ) (Tree, []*runtime.ConfiguredComponent, fx.Option, error)
ParseNestedCircuit parses a nested circuit and returns the port mapping, children trees, leaf components, and options.
func RootTree ¶
func RootTree(circuitProto *policylangv1.Circuit) (Tree, error)
RootTree returns Tree to represent Circuit root.
func (*Tree) ExpandCircuit ¶
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 ¶
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 ¶
func (tree *Tree) GetSubGraph(componentID runtime.ComponentID, depth int) (*policymonitoringv1.Graph, error)
GetSubGraph returns a subgraph of the tree.