runtime

package
v0.1.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircuitModule

func CircuitModule() fx.Option

CircuitModule returns fx options of Circuit for the main app.

Types

type Circuit

type Circuit struct {
	// Policy Read API
	iface.PolicyRead
	// contains filtered or unexported fields
}

Circuit manages the runtime state of a set of components and their inter linkages via signals.

func NewCircuitAndOptions

func NewCircuitAndOptions(compWithPortsList []CompiledComponentAndPorts, policyReadAPI iface.PolicyRead) (*Circuit, fx.Option)

NewCircuitAndOptions create a new Circuit struct along with fx options.

func (*Circuit) Execute

func (circuit *Circuit) Execute(tickInfo TickInfo) error

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.PolicyRead
	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
}

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 PortToSignal

type PortToSignal map[string][]Signal

PortToSignal is a map from port name to a slice of Signals.

type PortToValue

type PortToValue map[string][]reading.Reading

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

type Signal struct {
	Name   string
	Looped bool
}

Signal represents a logical flow of Readings in a circuit and determines the linkage between Components.

type TickEndCallback

type TickEndCallback func(tickInfo TickInfo) error

TickEndCallback is a function that is called when a tick ends.

type TickInfo

type TickInfo struct {
	Timestamp     time.Time
	NextTimestamp time.Time
	Tick          int
	Interval      time.Duration
}

TickInfo is a struct that contains information about the current tick.

Jump to

Keyboard shortcuts

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