freepsgraph

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const ROOT_SYMBOL = "_"

Variables

View Source
var DefaultGraphEngineConfig = GraphEngineConfig{GraphsFromFile: []string{}, GraphsFromURL: []string{}, Graphs: map[string]GraphDesc{}}
View Source
var DefaultTelegramConfig = TelegramConfig{Token: ""}

Functions

func CaptureRaspiStill

func CaptureRaspiStill(cameraParams map[string]string) (bytes []byte, err error)

Types

type CollectedError

type CollectedError struct {
	Input     *OperatorIO
	Error     string
	Time      time.Time
	GraphName string
	Operation *GraphOperationDesc
}

CollectedError store an error, the timestamp and the name of the graph and operation

type CollectedErrors

type CollectedErrors struct {
	// contains filtered or unexported fields
}

CollectedErrors is a top-k-list of CollectedError

func NewCollectedErrors

func NewCollectedErrors(maxLen int) *CollectedErrors

NewCollectedErrors creates a new CollectedErrors

func (*CollectedErrors) AddError

func (ce *CollectedErrors) AddError(input *OperatorIO, err *OperatorIO, graphName string, od *GraphOperationDesc)

AddError adds an error to the CollectedErrors

func (*CollectedErrors) GetErrorsForGraph

func (ce *CollectedErrors) GetErrorsForGraph(since time.Time, graphName string) []*CollectedError

GetErrorsForGraph returns the error that occured in the given duration for a gien graph

func (*CollectedErrors) GetErrorsSince

func (ce *CollectedErrors) GetErrorsSince(d time.Duration) []*CollectedError

GetErrorsSince returns the error that occured in the given duration

type DedupArgs

type DedupArgs struct {
	Retention string
}

type EditConfigData

type EditConfigData struct {
	ConfigText string
	Output     string
}

type EvalArgs

type EvalArgs struct {
	ValueName string
	ValueType string
	Operation string
	Operand   interface{}
	Output    string
}

type FieldWithType

type FieldWithType struct {
	FieldType  string
	FieldValue string
}

type FreepsOperator

type FreepsOperator interface {
	// GetOutputType() OutputT
	Execute(fn string, mainArgs map[string]string, mainInput *OperatorIO) *OperatorIO

	GetFunctions() []string // returns a list of functions that this operator can execute
	GetPossibleArgs(fn string) []string
	GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string
}

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph is the instance created from a GraphDesc and contains the runtime data

func NewGraph

func NewGraph(name string, graphDesc *GraphDesc, ge *GraphEngine) (*Graph, error)

NewGraph creates a new graph from a graph description

func (*Graph) ToDot

func (g *Graph) ToDot(gd *GraphDesc) string

type GraphDesc

type GraphDesc struct {
	Tags       []string
	Source     string
	OutputFrom string
	Operations []GraphOperationDesc
}

GraphDesc contains a number of operations and defines which output to use

type GraphEngine

type GraphEngine struct {
	// contains filtered or unexported fields
}

GraphEngine holds all available graphs and operators

func NewGraphEngine

func NewGraphEngine(cr *utils.ConfigReader, cancel context.CancelFunc) *GraphEngine

NewGraphEngine creates the graph engine from the config

func (*GraphEngine) AddExternalGraph

func (ge *GraphEngine) AddExternalGraph(graphName string, gd *GraphDesc, fileName string) error

AddExternalGraph adds a graph to the external graph list and stores it in the config directory

func (*GraphEngine) AddExternalGraphs

func (ge *GraphEngine) AddExternalGraphs(graphs map[string]GraphDesc, fileName string) error

AddExternalGraphs adds a graph to the external graph list and stores it in the config directory

func (*GraphEngine) AddTemporaryGraph

func (ge *GraphEngine) AddTemporaryGraph(graphName string, gd *GraphDesc) error

AddTemporaryGraph adds a graph to the temporary graph list

func (*GraphEngine) CheckGraph

func (ge *GraphEngine) CheckGraph(graphName string) *OperatorIO

CheckGraph checks if the graph is valid

func (*GraphEngine) DeleteTemporaryGraph

func (ge *GraphEngine) DeleteTemporaryGraph(graphName string)

DeleteTemporaryGraph deletes the graph from the temporary graph list

func (*GraphEngine) ExecuteGraph

func (ge *GraphEngine) ExecuteGraph(graphName string, mainArgs map[string]string, mainInput *OperatorIO) *OperatorIO

ExecuteGraph executes a graph stored in the engine

func (*GraphEngine) ExecuteOperatorByName

func (ge *GraphEngine) ExecuteOperatorByName(logger log.FieldLogger, opName string, fn string, mainArgs map[string]string, mainInput *OperatorIO) *OperatorIO

ExecuteOperatorByName executes an operator directly

func (*GraphEngine) GetAllGraphDesc

func (ge *GraphEngine) GetAllGraphDesc() map[string]*GraphDesc

GetAllGraphDesc returns all graphs by name

func (*GraphEngine) GetGraphDesc

func (ge *GraphEngine) GetGraphDesc(graphName string) (*GraphDesc, bool)

GetGraphDesc returns the graph description stored under graphName

func (*GraphEngine) GetOperator

func (ge *GraphEngine) GetOperator(opName string) FreepsOperator

GetOperator returns the operator with the given name

func (*GraphEngine) GetOperators

func (ge *GraphEngine) GetOperators() []string

GetOperators returns the list of available operators

func (*GraphEngine) HasOperator

func (ge *GraphEngine) HasOperator(opName string) bool

HasOperator returns true if this operator is available in the engine

func (*GraphEngine) ReadConfig

func (ge *GraphEngine) ReadConfig() GraphEngineConfig

ReadConfig reads the config from the config reader

func (*GraphEngine) ReloadRequested

func (ge *GraphEngine) ReloadRequested() bool

ReloadRequested returns true if a reload was requested instead of a restart

type GraphEngineConfig

type GraphEngineConfig struct {
	Graphs         map[string]GraphDesc
	GraphsFromURL  []string
	GraphsFromFile []string
}

GraphEngineConfig is the configuration for the GraphEngine

type GraphOperationDesc

type GraphOperationDesc struct {
	Name            string `json:",omitempty"`
	Operator        string
	Function        string
	Arguments       map[string]string `json:",omitempty"`
	InputFrom       string            `json:",omitempty"`
	ExecuteOnFailOf string            `json:",omitempty"`
	ArgumentsFrom   string            `json:",omitempty"`
	IgnoreMainArgs  bool              `json:",omitempty"`
}

GraphOperationDesc defines which operator to execute with Arguments and where to take the input from

func (gop *GraphOperationDesc) ToQuicklink() string

ToQuicklink returns the URL to call a standalone-operation outside of a Graph

type InMemoryStore

type InMemoryStore struct {
	// contains filtered or unexported fields
}

func (*InMemoryStore) GetNamespace

func (s *InMemoryStore) GetNamespace(ns string) *StoreNamespace

GetNamespace from the store, create if it does not exist

func (*InMemoryStore) GetNamespaces

func (s *InMemoryStore) GetNamespaces() []string

GetNamespaces returns all namespaces

type JsonArgs

type JsonArgs struct {
	Measurement    string
	Tags           map[string]string
	Fields         map[string]interface{}
	FieldsWithType map[string]FieldWithType
}

type MessageAndTime

type MessageAndTime struct {
	// contains filtered or unexported fields
}

type OpCurl

type OpCurl struct {
}

func (*OpCurl) Execute

func (o *OpCurl) Execute(function string, vars map[string]string, mainInput *OperatorIO) *OperatorIO

func (*OpCurl) GetArgSuggestions

func (o *OpCurl) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpCurl) GetFunctions

func (o *OpCurl) GetFunctions() []string

func (*OpCurl) GetPossibleArgs

func (o *OpCurl) GetPossibleArgs(fn string) []string

type OpEval

type OpEval struct {
	// contains filtered or unexported fields
}

func (*OpEval) Eval

func (m *OpEval) Eval(vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpEval) EvalFloat

func (m *OpEval) EvalFloat(vInterface interface{}, op string, v2Interface interface{}) (bool, error)

func (*OpEval) EvalInt

func (m *OpEval) EvalInt(vInterface interface{}, op string, v2Interface interface{}) (bool, error)

func (*OpEval) EvalString

func (m *OpEval) EvalString(vInterface interface{}, op string, v2Interface interface{}) (bool, error)

func (*OpEval) Execute

func (m *OpEval) Execute(fn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpEval) Flatten

func (m *OpEval) Flatten(vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpEval) GetArgSuggestions

func (m *OpEval) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpEval) GetFunctions

func (m *OpEval) GetFunctions() []string

func (*OpEval) GetPossibleArgs

func (m *OpEval) GetPossibleArgs(fn string) []string

func (*OpEval) Regexp

func (m *OpEval) Regexp(args map[string]string, input *OperatorIO) *OperatorIO

type OpFlux

type OpFlux struct {
	// contains filtered or unexported fields
}

func NewFluxMod

func NewFluxMod(cr *utils.ConfigReader) *OpFlux

func (*OpFlux) Execute

func (o *OpFlux) Execute(fn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpFlux) GetArgSuggestions

func (o *OpFlux) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpFlux) GetFunctions

func (o *OpFlux) GetFunctions() []string

func (*OpFlux) GetPossibleArgs

func (o *OpFlux) GetPossibleArgs(fn string) []string

type OpFritz

type OpFritz struct {
	// contains filtered or unexported fields
}

func NewOpFritz

func NewOpFritz(cr *utils.ConfigReader) *OpFritz

NewOpFritz creates a new operator for Freeps and Freepsflux

func (*OpFritz) Execute

func (m *OpFritz) Execute(mixedCaseFn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpFritz) GetArgSuggestions

func (m *OpFritz) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpFritz) GetDeviceByAIN

func (m *OpFritz) GetDeviceByAIN(AIN string) (*freepslib.AvmDevice, error)

GetDeviceByAIN returns the device object for the device with the given AIN

func (*OpFritz) GetDevices

func (m *OpFritz) GetDevices() map[string]string

GetDevices returns a map of all devices

func (*OpFritz) GetFunctions

func (m *OpFritz) GetFunctions() []string

func (*OpFritz) GetPossibleArgs

func (m *OpFritz) GetPossibleArgs(fn string) []string

func (*OpFritz) GetTemplates

func (m *OpFritz) GetTemplates() map[string]string

GetTemplates returns a map of all templates

type OpGraph

type OpGraph struct {
	// contains filtered or unexported fields
}

func (*OpGraph) Execute

func (o *OpGraph) Execute(fn string, args map[string]string, input *OperatorIO) *OperatorIO

func (*OpGraph) GetArgSuggestions

func (o *OpGraph) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpGraph) GetFunctions

func (o *OpGraph) GetFunctions() []string

GetFunctions returns a list of graphs stored in the engine

func (*OpGraph) GetPossibleArgs

func (o *OpGraph) GetPossibleArgs(fn string) []string

type OpMQTT

type OpMQTT struct {
}

func NewMQTTOp

func NewMQTTOp(cr *utils.ConfigReader) *OpMQTT

func (*OpMQTT) Execute

func (o *OpMQTT) Execute(fn string, args map[string]string, input *OperatorIO) *OperatorIO

func (*OpMQTT) GetArgSuggestions

func (o *OpMQTT) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpMQTT) GetFunctions

func (o *OpMQTT) GetFunctions() []string

func (*OpMQTT) GetPossibleArgs

func (o *OpMQTT) GetPossibleArgs(fn string) []string

type OpMutt

type OpMutt struct{}

func (*OpMutt) Execute

func (o *OpMutt) Execute(fn string, args map[string]string, input *OperatorIO) *OperatorIO

func (*OpMutt) GetArgSuggestions

func (o *OpMutt) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpMutt) GetFunctions

func (o *OpMutt) GetFunctions() []string

GetFunctions returns a list of graphs stored in the engine

func (*OpMutt) GetPossibleArgs

func (o *OpMutt) GetPossibleArgs(fn string) []string

type OpRaspistill

type OpRaspistill struct {
}

func (*OpRaspistill) Execute

func (m *OpRaspistill) Execute(fn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpRaspistill) GetArgSuggestions

func (m *OpRaspistill) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpRaspistill) GetFunctions

func (m *OpRaspistill) GetFunctions() []string

func (*OpRaspistill) GetPossibleArgs

func (m *OpRaspistill) GetPossibleArgs(fn string) []string

type OpStore

type OpStore struct {
	// contains filtered or unexported fields
}

func NewOpStore

func NewOpStore() *OpStore

NewOpStore creates a new store operator

func (*OpStore) Execute

func (o *OpStore) Execute(fn string, args map[string]string, input *OperatorIO) *OperatorIO

Execute gets, sets or deletes a value from the store

func (*OpStore) GetArgSuggestions

func (o *OpStore) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

GetArgSuggestions returns suggestions for arguments

func (*OpStore) GetFunctions

func (o *OpStore) GetFunctions() []string

GetFunctions returns the functions of this operator

func (*OpStore) GetPossibleArgs

func (o *OpStore) GetPossibleArgs(fn string) []string

GetPossibleArgs returns the possible arguments for a function

type OpSystem

type OpSystem struct {
	// contains filtered or unexported fields
}

func NewSytemOp

func NewSytemOp(ge *GraphEngine, cancel context.CancelFunc) *OpSystem

func (*OpSystem) Execute

func (o *OpSystem) Execute(fn string, args map[string]string, input *OperatorIO) *OperatorIO

func (*OpSystem) GetArgSuggestions

func (o *OpSystem) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpSystem) GetFunctions

func (o *OpSystem) GetFunctions() []string

func (*OpSystem) GetPossibleArgs

func (o *OpSystem) GetPossibleArgs(fn string) []string

type OpTelegram

type OpTelegram struct {
	// contains filtered or unexported fields
}

func NewTelegramBot

func NewTelegramBot(cr *utils.ConfigReader) *OpTelegram

func (*OpTelegram) Execute

func (m *OpTelegram) Execute(fn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpTelegram) GetArgSuggestions

func (m *OpTelegram) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpTelegram) GetFunctions

func (m *OpTelegram) GetFunctions() []string

func (*OpTelegram) GetPossibleArgs

func (m *OpTelegram) GetPossibleArgs(fn string) []string

type OpTemplate

type OpTemplate struct {
	// contains filtered or unexported fields
}

func NewTemplateOperator

func NewTemplateOperator(ge *GraphEngine, cr *utils.ConfigReader) *OpTemplate

func (*OpTemplate) Execute

func (o *OpTemplate) Execute(fn string, mainArgs map[string]string, mainInput *OperatorIO) *OperatorIO

func (*OpTemplate) GetArgSuggestions

func (o *OpTemplate) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpTemplate) GetFunctions

func (o *OpTemplate) GetFunctions() []string

func (*OpTemplate) GetPossibleArgs

func (o *OpTemplate) GetPossibleArgs(fn string) []string

type OpTime

type OpTime struct {
}

func (*OpTime) Execute

func (o *OpTime) Execute(function string, vars map[string]string, mainInput *OperatorIO) *OperatorIO

func (*OpTime) GetArgSuggestions

func (o *OpTime) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpTime) GetFunctions

func (o *OpTime) GetFunctions() []string

func (*OpTime) GetPossibleArgs

func (o *OpTime) GetPossibleArgs(fn string) []string

type OpUI

type OpUI struct {
	// contains filtered or unexported fields
}

func NewHTMLUI

func NewHTMLUI(cr *utils.ConfigReader, graphEngine *GraphEngine) *OpUI

NewHTMLUI creates a UI interface based on the inline template above

func (*OpUI) Execute

func (o *OpUI) Execute(fn string, vars map[string]string, input *OperatorIO) *OperatorIO

func (*OpUI) GetArgSuggestions

func (o *OpUI) GetArgSuggestions(fn string, arg string, otherArgs map[string]string) map[string]string

func (*OpUI) GetFunctions

func (o *OpUI) GetFunctions() []string

func (*OpUI) GetPossibleArgs

func (o *OpUI) GetPossibleArgs(fn string) []string

type OperatorIO

type OperatorIO struct {
	OutputType  OutputT
	HTTPCode    uint32
	Output      interface{}
	ContentType string
}

OperatorIO is the input and output of an operator, once created it should not be modified Note: the Store Operator depends on this struct being immutable

func MakeByteOutput

func MakeByteOutput(output []byte) *OperatorIO

func MakeByteOutputWithContentType

func MakeByteOutputWithContentType(output []byte, contentType string) *OperatorIO

func MakeEmptyOutput

func MakeEmptyOutput() *OperatorIO

func MakeObjectOutput

func MakeObjectOutput(output interface{}) *OperatorIO

func MakeOutputError

func MakeOutputError(code uint32, msg string, a ...interface{}) *OperatorIO

func MakePlainOutput

func MakePlainOutput(msg string, a ...interface{}) *OperatorIO

func (*OperatorIO) GetArgsMap

func (io *OperatorIO) GetArgsMap() (map[string]string, error)

func (*OperatorIO) GetBytes

func (io *OperatorIO) GetBytes() ([]byte, error)

func (*OperatorIO) GetError

func (io *OperatorIO) GetError() error

func (*OperatorIO) GetString

func (io *OperatorIO) GetString() string

func (*OperatorIO) IsEmpty

func (io *OperatorIO) IsEmpty() bool

func (*OperatorIO) IsError

func (io *OperatorIO) IsError() bool

func (*OperatorIO) IsPlain

func (io *OperatorIO) IsPlain() bool

func (*OperatorIO) Log

func (oio *OperatorIO) Log(logger logrus.FieldLogger)

func (*OperatorIO) ParseFormData

func (io *OperatorIO) ParseFormData() (url.Values, error)

ParseFormData returns the data as posted by a HTML form

func (*OperatorIO) ParseJSON

func (io *OperatorIO) ParseJSON(obj interface{}) error

func (*OperatorIO) ToString

func (oio *OperatorIO) ToString() string

func (*OperatorIO) WriteTo

func (oio *OperatorIO) WriteTo(bwriter io.Writer) (int, error)

type OutputT

type OutputT string
const (
	Empty     OutputT = ""
	Error     OutputT = "error"
	PlainText OutputT = "plain"
	Byte      OutputT = "byte"
	Object    OutputT = "object"
)

type ShowGraphsData

type ShowGraphsData struct {
	Graphs    []string
	GraphJSON string
	Output    string
}

type StoreNamespace

type StoreNamespace struct {
	// contains filtered or unexported fields
}

func (*StoreNamespace) DeleteValue

func (s *StoreNamespace) DeleteValue(key string)

DeleteValue from the StoreNamespace

func (*StoreNamespace) GetAllValues

func (s *StoreNamespace) GetAllValues() map[string]*OperatorIO

GetAllValues from the StoreNamespace

func (*StoreNamespace) GetKeys

func (s *StoreNamespace) GetKeys() []string

GetKeys returns all keys in the StoreNamespace

func (*StoreNamespace) GetValue

func (s *StoreNamespace) GetValue(key string) *OperatorIO

GetValue from the StoreNamespace

func (*StoreNamespace) SetValue

func (s *StoreNamespace) SetValue(key string, io *OperatorIO)

SetValue in the StoreNamespace

type SunriseOutput

type SunriseOutput struct {
	Begin     time.Time
	End       time.Time
	Phase     string
	Latitude  float64
	Longitude float64
	Since     time.Duration
	Until     time.Duration
}

type TelegramConfig

type TelegramConfig struct {
	Token         string
	AllowedUsers  []string
	DebugMessages bool
}

type TemplateData

type TemplateData struct {
	Args                 map[string]string
	OpSuggestions        map[string]bool
	FnSuggestions        map[string]bool
	ArgSuggestions       map[string]map[string]string
	InputFromSuggestions []string
	GraphName            string
	GraphDesc            *GraphDesc
	GraphJSON            string
	Output               string
	Numop                int
	Quicklink            string
	Error                string
}

Jump to

Keyboard shortcuts

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