Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CircuitModule ¶
CircuitModule returns fx options of Circuit for the main app.
Types ¶
type Circuit ¶
Circuit manages the runtime state of a set of components and their inter linkages via signals.
func NewCircuitAndOptions ¶
func NewCircuitAndOptions(compWithPortsList []CompiledComponentAndPorts, policyReadAPI iface.Policy) (*Circuit, fx.Option)
NewCircuitAndOptions create a new Circuit struct along with fx options.
func (*Circuit) Execute ¶
Execute runs one tick of computations of all the Components in the Circuit.
func (*Circuit) LockExecution ¶
func (circuit *Circuit) LockExecution()
LockExecution locks the execution of the circuit.
func (*Circuit) RegisterTickEndCallback ¶
func (circuit *Circuit) RegisterTickEndCallback(cb TickEndCallback)
RegisterTickEndCallback adds a callback function to be called when a tick ends.
func (*Circuit) UnlockExecution ¶
func (circuit *Circuit) UnlockExecution()
UnlockExecution unlocks the execution of the circuit.
type CircuitAPI ¶
type CircuitAPI interface { iface.Policy RegisterTickEndCallback(cb TickEndCallback) LockExecution() UnlockExecution() }
CircuitAPI is for read only access to policy and also provides methods for acquiring & releasing circuit execution lock.
type CircuitMetrics ¶
type CircuitMetrics struct {
SignalSummaryVec *prometheus.SummaryVec
}
CircuitMetrics holds prometheus metrics related circuit.
type CompiledComponent ¶
type CompiledComponent struct { Component Component MapStruct map[string]any Name string ComponentType ComponentType }
CompiledComponent consists of a Component, its MapStruct and Name.
type CompiledComponentAndPorts ¶
type CompiledComponentAndPorts struct { InPortToSignalsMap PortToSignal OutPortToSignalsMap PortToSignal CompiledComponent CompiledComponent }
CompiledComponentAndPorts consists of a CompiledComponent and its In and Out ports.
type Component ¶
type Component interface {
Execute(inPortReadings PortToValue, tickInfo TickInfo) (outPortReadings PortToValue, err error)
}
Component is the interface that all components must implement.
type ComponentType ¶
type ComponentType string
ComponentType describes the type of a component based on its connectivity in the circuit.
const ( // ComponentTypeStandAlone is a component that is not connected to any other component. ComponentTypeStandAlone ComponentType = "StandAlone" // ComponentTypeSource is a component that emits output signal(s) but does not accept an input signal. ComponentTypeSource ComponentType = "Source" // ComponentTypeSink is a component that accepts input signal(s) but does not emit an output signal. ComponentTypeSink ComponentType = "Sink" // ComponentTypeSignalProcessor is a component that accepts input signal(s) and emits output signal(s). ComponentTypeSignalProcessor ComponentType = "SignalProcessor" )
type PortToSignal ¶
PortToSignal is a map from port name to a slice of Signals.
type PortToValue ¶
PortToValue is a map from port name to a slice of Readings.
func (PortToValue) ReadRepeatedValuePort ¶
func (ptv PortToValue) ReadRepeatedValuePort(portName string) []reading.Reading
ReadRepeatedValuePort returns the reading of all the signals at port=portName. If no signal is found, []reading.Reading{} empty list is returned.
func (PortToValue) ReadSingleValuePort ¶
func (ptv PortToValue) ReadSingleValuePort(portName string) reading.Reading
ReadSingleValuePort returns the reading of the first signal at port=portName. If no signal is found, reading.NewInvalid() is returned.
type Signal ¶
Signal represents a logical flow of Readings in a circuit and determines the linkage between Components.
type TickEndCallback ¶
TickEndCallback is a function that is called when a tick ends.