freepsgraph

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 27 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{}, AlertDuration: time.Hour}

Functions

func SplitTag added in v1.3.0

func SplitTag(tag string) (string, string)

SplitTag returns the tag name and the value of the tag if any (split by the first ":")

Types

type DedupArgs

type DedupArgs struct {
	Retention string
}

type EvalArgs

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

type FreepsAlertHook added in v1.3.0

type FreepsAlertHook interface {
	OnSystemAlert(ctx *base.Context, name string, category string, severity int, err error, expiresIn *time.Duration) error
	OnResetSystemAlert(ctx *base.Context, name string, category string) error
}

type FreepsExecutionHook added in v1.3.0

type FreepsExecutionHook interface {
	OnExecute(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO) error
	OnExecuteOperation(ctx *base.Context, input *base.OperatorIO, opOutput *base.OperatorIO, graphName string, od *GraphOperationDesc) error
	OnExecutionFinished(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO) error
}

type FreepsGraphChangedHook added in v1.3.0

type FreepsGraphChangedHook interface {
	OnGraphChanged(ctx *base.Context, addedGraphName []string, removedGraphName []string) error
}

type FreepsHookWrapper added in v1.3.0

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

func NewFreepsHookWrapper added in v1.3.0

func NewFreepsHookWrapper(hookImpl interface{}) *FreepsHookWrapper

func (*FreepsHookWrapper) GetName added in v1.3.0

func (h *FreepsHookWrapper) GetName() string

func (*FreepsHookWrapper) OnExecute added in v1.3.0

func (h *FreepsHookWrapper) OnExecute(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO) error

func (*FreepsHookWrapper) OnExecuteOperation added in v1.3.0

func (h *FreepsHookWrapper) OnExecuteOperation(ctx *base.Context, input *base.OperatorIO, opOutput *base.OperatorIO, graphName string, od *GraphOperationDesc) error

func (*FreepsHookWrapper) OnExecutionFinished added in v1.3.0

func (h *FreepsHookWrapper) OnExecutionFinished(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO) error

func (*FreepsHookWrapper) OnGraphChanged added in v1.3.0

func (h *FreepsHookWrapper) OnGraphChanged(ctx *base.Context, addedGraphName []string, removedGraphName []string) error

func (*FreepsHookWrapper) OnResetSystemAlert added in v1.3.0

func (h *FreepsHookWrapper) OnResetSystemAlert(ctx *base.Context, name string, category string) error

func (*FreepsHookWrapper) OnSystemAlert added in v1.3.0

func (h *FreepsHookWrapper) OnSystemAlert(ctx *base.Context, name string, category string, severity int, err error, expiresIn *time.Duration) error

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(ctx *base.Context, graphID string, origGraphDesc *GraphDesc, ge *GraphEngine) (*Graph, error)

NewGraph creates a new graph from a graph description

func (*Graph) GetCompleteDesc added in v1.3.0

func (g *Graph) GetCompleteDesc() *GraphDesc

GetCompleteDesc returns the GraphDesc that was sanitized and completed when creating the graph

func (*Graph) GetGraphID added in v1.3.0

func (g *Graph) GetGraphID() string

GetGraphID returns the unique ID for this graph in the graph engine

func (*Graph) ToDot

func (g *Graph) ToDot(ctx *base.Context) []byte

ToDot creates the Graphviz/dot represantion of a graph

type GraphDesc

type GraphDesc struct {
	GraphID     string `json:",omitempty"` // is only assigned when the graph is added to the engine and will be overwritten
	DisplayName string
	Tags        []string
	Source      string
	OutputFrom  string
	Operations  []GraphOperationDesc
}

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

func (*GraphDesc) AddTags added in v1.3.0

func (gd *GraphDesc) AddTags(tags ...string)

AddTags adds a Tag to the description and removes duplicates

func (*GraphDesc) GetCompleteDesc added in v1.3.0

func (gd *GraphDesc) GetCompleteDesc(graphID string, ge *GraphEngine) (*GraphDesc, error)

GetCompleteDesc initializes and validates the GraphDescription and returns a copy in order to create a Graph

func (*GraphDesc) HasAllTags added in v1.3.0

func (gd *GraphDesc) HasAllTags(expectedTags []string) bool

HasAllTags return true if the GraphDesc contains all given tags

func (*GraphDesc) HasAtLeastOneTag added in v1.3.0

func (gd *GraphDesc) HasAtLeastOneTag(expectedTags []string) bool

HasAtLeastOneTag returns true if the GraphDesc contains at least one of the given tags

func (*GraphDesc) HasAtLeastOneTagPerGroup added in v1.3.0

func (gd *GraphDesc) HasAtLeastOneTagPerGroup(tagGroups ...[]string) bool

HasAtLeastOneTagPerGroup returns true if the GraphDesc contains at least one tag of each array

func (*GraphDesc) RemoveTag added in v1.3.0

func (gd *GraphDesc) RemoveTag(tag string)

RemoveTag removes a Tag and duplicates in general from the description

func (*GraphDesc) RenameOperation added in v1.3.0

func (gd *GraphDesc) RenameOperation(oldName string, newName string)

RenameOperation renames an operation oldName to newName everywhere in the Graph

type GraphEngine

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

GraphEngine holds all available graphs and operators

func NewGraphEngine

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

NewGraphEngine creates the graph engine from the config

func (*GraphEngine) AddGraph added in v1.3.0

func (ge *GraphEngine) AddGraph(ctx *base.Context, graphID string, gd GraphDesc, overwrite bool) error

AddGraph adds a graph from an external source and stores it on disk, after checking if the graph is valid

func (*GraphEngine) AddHook added in v1.2.0

func (ge *GraphEngine) AddHook(h GraphEngineHook)

AddHook adds a hook to the graph engine

func (*GraphEngine) AddOperator added in v1.2.0

func (ge *GraphEngine) AddOperator(op base.FreepsBaseOperator)

AddOperator adds an operator to the graph engine

func (*GraphEngine) AddOperators added in v1.3.0

func (ge *GraphEngine) AddOperators(ops []base.FreepsBaseOperator)

AddOperators adds multiple operators to the graph engine

func (*GraphEngine) CheckGraph

func (ge *GraphEngine) CheckGraph(graphID string) *base.OperatorIO

CheckGraph checks if the graph is valid

func (*GraphEngine) DeleteGraph added in v1.2.0

func (ge *GraphEngine) DeleteGraph(ctx *base.Context, graphID string) (*GraphDesc, error)

DeleteGraph removes a graph from the engine and from the storage

func (*GraphEngine) ExecuteAdHocGraph added in v1.3.0

func (ge *GraphEngine) ExecuteAdHocGraph(ctx *base.Context, fullName string, gd GraphDesc, mainArgs map[string]string, mainInput *base.OperatorIO) *base.OperatorIO

ExecuteAdHocGraph executes a graph directly

func (*GraphEngine) ExecuteGraph

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

ExecuteGraph executes a graph stored in the engine

func (*GraphEngine) ExecuteGraphByTags added in v1.2.0

func (ge *GraphEngine) ExecuteGraphByTags(ctx *base.Context, tags []string, args map[string]string, input *base.OperatorIO) *base.OperatorIO

ExecuteGraphByTags executes graphs with given tags

func (*GraphEngine) ExecuteGraphByTagsExtended added in v1.3.0

func (ge *GraphEngine) ExecuteGraphByTagsExtended(ctx *base.Context, tagGroups [][]string, args map[string]string, input *base.OperatorIO) *base.OperatorIO

ExecuteGraphByTagsExtended executes all graphs that at least one tag of each group

func (*GraphEngine) ExecuteOperatorByName

func (ge *GraphEngine) ExecuteOperatorByName(ctx *base.Context, opName string, fn string, mainArgs map[string]string, mainInput *base.OperatorIO) *base.OperatorIO

ExecuteOperatorByName executes an operator directly

func (*GraphEngine) GetAllGraphDesc

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

GetAllGraphDesc returns all graphs by name

func (*GraphEngine) GetCompleteGraphDesc added in v1.3.0

func (ge *GraphEngine) GetCompleteGraphDesc(graphID string) (*GraphDesc, error)

GetCompleteGraphDesc returns the sanitized, validated and complete graph description stored under graphName

func (*GraphEngine) GetGraphDesc

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

GetGraphDesc returns the graph description stored under graphID

func (*GraphEngine) GetGraphDescByTag added in v1.3.0

func (ge *GraphEngine) GetGraphDescByTag(tags []string) map[string]GraphDesc

GetGraphDescByTag returns the GraphInfo for all Graphs that cointain all of the given tags

func (*GraphEngine) GetGraphDescByTagExtended added in v1.3.0

func (ge *GraphEngine) GetGraphDescByTagExtended(tagGroups ...[]string) map[string]GraphDesc

GetGraphDescByTagExtended returns the GraphInfo for all Graphs that contain at least one tag of each group

func (*GraphEngine) GetGraphDir added in v1.3.0

func (ge *GraphEngine) GetGraphDir() string

GetGraphDir returns the directory where the graphs are stored

func (*GraphEngine) GetOperator

func (ge *GraphEngine) GetOperator(opName string) base.FreepsBaseOperator

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) GetTagMap added in v1.3.0

func (ge *GraphEngine) GetTagMap() map[string][]string

GetTagMap returns a map of all used tags and their values (empty array if no value)

func (*GraphEngine) GetTagValues added in v1.3.0

func (ge *GraphEngine) GetTagValues(keytag string) []string

GetTagValues returns a slice of all used values for the given tag

func (*GraphEngine) GetTags added in v1.1.0

func (ge *GraphEngine) GetTags() map[string]string

GetTags returns a map of all used tags TODO(HR): deprecate

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

func (*GraphEngine) ResetSystemAlert added in v1.3.0

func (ge *GraphEngine) ResetSystemAlert(ctx *base.Context, name string, category string)

ResetSystemAlert triggers the hooks with the same name

func (*GraphEngine) SetSystemAlert added in v1.3.0

func (ge *GraphEngine) SetSystemAlert(ctx *base.Context, name string, category string, severity int, err error, expiresIn *time.Duration)

SetSystemAlert triggers the hooks with the same name

func (*GraphEngine) Shutdown added in v1.1.0

func (ge *GraphEngine) Shutdown(ctx *base.Context)

Shutdown should be called for graceful shutdown

func (*GraphEngine) StartListening added in v1.3.0

func (ge *GraphEngine) StartListening(ctx *base.Context)

StartListening starts all listening operators

func (*GraphEngine) TriggerGraphChangedHooks added in v1.3.0

func (ge *GraphEngine) TriggerGraphChangedHooks(ctx *base.Context, addedGraphNames []string, removedGraphNames []string)

TriggerGraphChangedHooks triggers hooks whenever a graph was added or removed

func (*GraphEngine) TriggerOnExecuteHooks added in v1.2.0

func (ge *GraphEngine) TriggerOnExecuteHooks(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO)

TriggerOnExecuteHooks adds a hook to the graph engine

func (*GraphEngine) TriggerOnExecuteOperationHooks added in v1.3.0

func (ge *GraphEngine) TriggerOnExecuteOperationHooks(ctx *base.Context, input *base.OperatorIO, output *base.OperatorIO, graphName string, od *GraphOperationDesc)

TriggerOnExecuteOperationHooks executes hooks immediately after an operation was executed

func (*GraphEngine) TriggerOnExecutionFinishedHooks added in v1.2.0

func (ge *GraphEngine) TriggerOnExecutionFinishedHooks(ctx *base.Context, graphName string, mainArgs map[string]string, mainInput *base.OperatorIO)

TriggerOnExecutionFinishedHooks executes hooks when Execution of a graph finishes

type GraphEngineConfig

type GraphEngineConfig struct {
	Graphs         map[string]GraphDesc
	GraphsFromURL  []string
	GraphsFromFile []string
	AlertDuration  time.Duration
}

GraphEngineConfig is the configuration for the GraphEngine

type GraphEngineHook added in v1.3.0

type GraphEngineHook interface {
	GetName() string
}

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"` // deprecate
	UseMainArgs     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 MessageAndTime

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

type OpEval

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

func (*OpEval) Eval

func (m *OpEval) Eval(vars map[string]string, input *base.OperatorIO) *base.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(ctx *base.Context, fn string, vars map[string]string, input *base.OperatorIO) *base.OperatorIO

func (*OpEval) Flatten

func (m *OpEval) Flatten(vars map[string]string, input *base.OperatorIO) *base.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) GetHook added in v1.3.0

func (o *OpEval) GetHook() interface{}

GetHook returns the hook for this operator

func (*OpEval) GetName added in v1.2.0

func (o *OpEval) GetName() string

GetName returns the name of the operator

func (*OpEval) GetPossibleArgs

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

func (*OpEval) Regexp

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

func (*OpEval) Shutdown added in v1.2.0

func (o *OpEval) Shutdown(ctx *base.Context)

Shutdown (noOp)

func (*OpEval) Split added in v1.3.0

func (m *OpEval) Split(argsmap map[string]string, input *base.OperatorIO) *base.OperatorIO

func (*OpEval) StartListening added in v1.3.0

func (o *OpEval) StartListening(ctx *base.Context)

StartListening (noOp)

type OpGraph

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

func (*OpGraph) Execute

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

func (*OpGraph) GetArgSuggestions

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

GetArgSuggestions returns suggestions based on the suggestions of the operators in the graph

func (*OpGraph) GetFunctions

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

GetFunctions returns a list of graphs stored in the engine

func (*OpGraph) GetHook added in v1.3.0

func (o *OpGraph) GetHook() interface{}

GetHook returns the hook for this operator

func (*OpGraph) GetName added in v1.2.0

func (o *OpGraph) GetName() string

GetName returns the name of the operator

func (*OpGraph) GetPossibleArgs

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

GetPossibleArgs returns suggestions based on the suggestions of the operators in the graph

func (*OpGraph) Shutdown added in v1.2.0

func (o *OpGraph) Shutdown(*base.Context)

Shutdown (noOp)

func (*OpGraph) StartListening added in v1.3.0

func (o *OpGraph) StartListening(*base.Context)

StartListening (noOp)

type OpGraphByTag added in v1.2.0

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

func (*OpGraphByTag) Execute added in v1.2.0

func (o *OpGraphByTag) Execute(ctx *base.Context, fn string, args map[string]string, input *base.OperatorIO) *base.OperatorIO

func (*OpGraphByTag) GetArgSuggestions added in v1.2.0

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

GetArgSuggestions returns addtional tags

func (*OpGraphByTag) GetFunctions added in v1.2.0

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

GetFunctions returns a list of all available tags

func (*OpGraphByTag) GetHook added in v1.3.0

func (o *OpGraphByTag) GetHook() interface{}

GetHook returns the hook for this operator

func (*OpGraphByTag) GetName added in v1.2.0

func (o *OpGraphByTag) GetName() string

GetName returns the name of the operator

func (*OpGraphByTag) GetPossibleArgs added in v1.2.0

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

GetPossibleArgs returns the additonalTags Option

func (*OpGraphByTag) Shutdown added in v1.2.0

func (o *OpGraphByTag) Shutdown(*base.Context)

Shutdown (noOp)

func (*OpGraphByTag) StartListening added in v1.3.0

func (o *OpGraphByTag) StartListening(*base.Context)

StartListening (noOp)

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(ctx *base.Context, fn string, args map[string]string, input *base.OperatorIO) *base.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) GetHook added in v1.3.0

func (o *OpSystem) GetHook() interface{}

GetHook (noOp)

func (*OpSystem) GetName added in v1.2.0

func (o *OpSystem) GetName() string

GetName returns the name of the operator

func (*OpSystem) GetPossibleArgs

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

func (*OpSystem) Shutdown added in v1.2.0

func (o *OpSystem) Shutdown(ctx *base.Context)

Shutdown (noOp)

func (*OpSystem) StartListening added in v1.3.0

func (o *OpSystem) StartListening(ctx *base.Context)

StartListening (noOp)

func (*OpSystem) Stats added in v1.3.0

func (o *OpSystem) Stats(ctx *base.Context, fn string, args map[string]string, input *base.OperatorIO) *base.OperatorIO

Jump to

Keyboard shortcuts

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