core

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name    = "driplane"
	Version = "1.16.1"
	Author  = "Gianluca Braga aka Matrix86"
)

Info on driplane

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST struct {
	Dependencies map[string]*AST
	Rules        []*RuleNode `@@*`
}

AST defines a set of Rules

type Configuration

type Configuration struct {
	sync.RWMutex

	FilePath string
	// contains filtered or unexported fields
}

Configuration contains all the configs read by yaml file

func LoadConfiguration

func LoadConfiguration(path string) (*Configuration, error)

LoadConfiguration create a Configuration struct from a filename

func (*Configuration) Get

func (c *Configuration) Get(name string) string

Get returns the config value with that name, if it exists

func (*Configuration) GetConfig

func (c *Configuration) GetConfig() map[string]string

GetConfig returns the complete configuration in a flatten way

func (*Configuration) Set

func (c *Configuration) Set(name string, value string) error

Set insert a new config in the Configuration struct

type FeederNode

type FeederNode struct {
	Name   string   `"<" @Ident`
	Params []*Param `(":" @@ ("," @@)*)? ">"`
	Next   *Node    `("|" @@)?`
}

FeederNode identifies the Feeder in the rule

type FilterNode

type FilterNode struct {
	Neg    bool     `@("!")?`
	Name   string   `@Ident`
	Params []*Param `"(" ( @@ ("," @@)* )? ")"`
	Next   *Node    `("|" @@)?`
}

FilterNode identifies the Filter in the rule

type INode

type INode interface{}

INode for the nodes generalization

type Node

type Node struct {
	//Action   *ActionNode `( @@ `
	Filter   *FilterNode `( @@`
	RuleCall *RuleCall   `| @@)`
}

Node identifies a Filter or a RuleCall

type Orchestrator

type Orchestrator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Orchestrator handles the pipelines and rules

func NewOrchestrator

func NewOrchestrator(config *Configuration) (Orchestrator, error)

NewOrchestrator create a new instance of the Orchestrator

func (*Orchestrator) HasRunningFeeder

func (o *Orchestrator) HasRunningFeeder() bool

HasRunningFeeder return true if one or more feeders are running

func (*Orchestrator) StartFeeders

func (o *Orchestrator) StartFeeders()

StartFeeders opens the gates

func (*Orchestrator) StopFeeders

func (o *Orchestrator) StopFeeders()

StopFeeders closes the gates

func (*Orchestrator) WaitFeeders

func (o *Orchestrator) WaitFeeders()

WaitFeeders waits until all the feeders are stopped

type Param

type Param struct {
	Name  string `@Ident "="`
	Value *Value `@@`
}

Param identifies the parameters accepted by nodes

type Parser

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

Parser handles the parsing of the rules

func NewParser

func NewParser() (*Parser, error)

NewParser creates a new Parser struct

func (*Parser) ParseFile

func (p *Parser) ParseFile(filename string) (*AST, error)

ParseFile fills the map with all the ASTs parsed from the input file

type PipeRule

type PipeRule struct {
	Name      string
	HasFeeder bool
	// contains filtered or unexported fields
}

PipeRule identifies a single rule

func NewPipeRule

func NewPipeRule(node *RuleNode, config *Configuration, filename string, deps []string) (*PipeRule, error)

NewPipeRule creates and returns a PipeRule struct

func (*PipeRule) GetIdentifier added in v1.3.1

func (p *PipeRule) GetIdentifier() string

GetIdentifier return the name with the file of the current Piperule

type RuleCall

type RuleCall struct {
	Name string `"@" @Ident`
	Next *Node  `("|" @@)?`
}

RuleCall identifies the Call nodes in the rule

type RuleNode

type RuleNode struct {
	Identifier string      `@Ident "="">"`
	Feeder     *FeederNode `( @@`
	First      *Node       `| @@ ) ";"`
}

RuleNode defines the first part of the Rule

type Ruleset

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

Ruleset identifies a set of rules

func RuleSetInstance

func RuleSetInstance() *Ruleset

RuleSetInstance is the singleton for the Ruleset object

func (*Ruleset) AddRule

func (r *Ruleset) AddRule(filename string, node *RuleNode, config *Configuration, deps []string) error

AddRule appends a new rule to the set

func (*Ruleset) CompileAst added in v1.3.1

func (r *Ruleset) CompileAst(filename string, ast *AST, config *Configuration) ([]string, error)

CompileAst compiles the AST

type Value

type Value struct {
	String *string  `  @String`
	Number *float64 `| @Float`
}

Value identifies a String or a Number

Jump to

Keyboard shortcuts

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