Documentation
¶
Index ¶
- Constants
- func CircuitModule() fx.Option
- type Circuit
- func (circuit *Circuit) DynamicConfigUpdate(event notifiers.Event, unmarshaller config.Unmarshaller)
- func (circuit *Circuit) Execute(tickInfo TickInfo) error
- func (circuit *Circuit) LockExecution()
- func (circuit *Circuit) RegisterTickEndCallback(ec TickEndCallback)
- func (circuit *Circuit) RegisterTickStartCallback(sc TickStartCallback)
- func (circuit *Circuit) UnlockExecution()
- type CircuitAPI
- type CircuitMetrics
- type CompiledComponent
- type CompiledComponentAndPorts
- type Component
- type ComponentType
- type PortToSignal
- type PortToValue
- type Reading
- type Signal
- type SignalType
- type TickEndCallback
- type TickInfo
- type TickStartCallback
Constants ¶
const ( // SignalTypeNamed is a named signal. SignalTypeNamed = iota // SignalTypeConstant is a constant signal. SignalTypeConstant )
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, registry status.Registry, ) (*Circuit, fx.Option)
NewCircuitAndOptions create a new Circuit struct along with fx options.
func (*Circuit) DynamicConfigUpdate ¶ added in v0.4.0
func (circuit *Circuit) DynamicConfigUpdate(event notifiers.Event, unmarshaller config.Unmarshaller)
DynamicConfigUpdate updates the circuit with the new dynamic config.
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(ec TickEndCallback)
RegisterTickEndCallback adds a callback function to be called when a tick ends.
func (*Circuit) RegisterTickStartCallback ¶ added in v0.2.1
func (circuit *Circuit) RegisterTickStartCallback(sc TickStartCallback)
RegisterTickStartCallback adds a callback function to be called when a tick starts.
func (*Circuit) UnlockExecution ¶
func (circuit *Circuit) UnlockExecution()
UnlockExecution unlocks the execution of the circuit.
type CircuitAPI ¶
type CircuitAPI interface { iface.Policy RegisterTickEndCallback(ec TickEndCallback) RegisterTickStartCallback(sc TickStartCallback) 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) DynamicConfigUpdate(event notifiers.Event, unmarshaller config.Unmarshaller) }
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 does not accept or emit any signals. 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
ReadRepeatedValuePort returns the reading of all the signals at port=portName. If no signal is found, []Reading{} empty list is returned.
func (PortToValue) ReadSingleValuePort ¶
func (ptv PortToValue) ReadSingleValuePort(portName string) Reading
ReadSingleValuePort returns the reading of the first signal at port=portName. If no signal is found, InvalidReading() is returned.
type Reading ¶ added in v0.2.1
Reading is the interface that reading implements which wraps a float Value which can be valid or invalid.
func InvalidReading ¶ added in v0.2.1
func InvalidReading() Reading
InvalidReading creates a reading with 'value' set to math.NaN(), invalid value.
func NewReading ¶ added in v0.2.1
NewReading creates a reading with the given value.
type Signal ¶
type Signal struct { Name string Value float64 Looped bool SignalType SignalType }
Signal represents a logical flow of Readings in a circuit and determines the linkage between Components.
func MakeSignal ¶ added in v0.5.0
func MakeSignal(signalType SignalType, name string, value float64, looped bool) Signal
MakeSignal creates a new Signal.
type TickEndCallback ¶
TickEndCallback is a function that is called when a tick ends.
type TickInfo ¶
type TickInfo interface { Timestamp() time.Time NextTimestamp() time.Time Tick() int Interval() time.Duration }
TickInfo is the interface that trackInfo implements which contains information about the current tick.
type TickStartCallback ¶ added in v0.2.1
TickStartCallback is a function that is called when a tick starts.