engine

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, e RuleEngine) error

Register registers the given rule engine

Types

type Config

type Config struct {
	// CoolDownPeriod is the period between 2 subsequent actions for a rule
	CoolDownPeriod time.Duration // optional
	// MinPollInterval is the minimum interval that's supported for quering
	// the policy conditions from the metrics server
	MinPollInterval time.Duration // optional
	// EventProviders is an array of EventProviders, which will generate events on state changing
	EventProviders []audit.EventProvider //required
}

Config represents the configuration for a rule engine

type RuleEngine

type RuleEngine interface {
	// Init initializes the rule engine
	Init(cfg *Config) error
	// Start starts the rule engine
	Start() error
	// Stop stops the rule engine
	Stop() error
	// AddRule adds the given rule to the rule engine. If the rule engine already
	// has the rule it should update it
	AddRule(rule *v1alpha1.AutopilotRule) error
	// DeleteRule deletes the given rule from the rule engine. Existing watches on
	// the conditions should be stopped by the rule engine
	DeleteRule(rule *v1alpha1.AutopilotRule) error
}

RuleEngine is an interface that a rule engine must implement

func Get

func Get(name string) (RuleEngine, error)

Get returns a registered rule engine

type RuleEvent

type RuleEvent string

RuleEvent is the type for events on a rule

const (
	// RuleEventWatch is the watch event on a rule
	RuleEventWatch RuleEvent = "Watch"
	// RuleEventConditionsMet is when the rule's conditions have been met
	RuleEventConditionsMet RuleEvent = "ConditionsMet"
	// RuleEventConditionsNotMet is when the rule's conditions have not been met
	RuleEventConditionsNotMet RuleEvent = "ConditionsNotMet"
	// RuleEventConditionsStable is when the rule's conditions have been held for
	// the condition hold time
	RuleEventConditionsStable RuleEvent = "ConditionsStable"
	// RuleEventActionTaken is when the rule's actions have been successfully
	// performed
	RuleEventActionTaken RuleEvent = "ActionsTaken"
	// RuleEventActionsCooledDown is when it has been more time than the cool down
	// period time since the last action was taken
	RuleEventActionsCooledDown RuleEvent = "ActionsCooledDown"
)

type RuleState

type RuleState string

RuleState is the type for the state of a rule

const (
	// RuleStateInit is the initial state of the rule where monitorign has not yet begin
	RuleStateInit RuleState = "Initializing"
	// RuleStateNormal is when the rule is being monitored and is in normal state
	RuleStateNormal RuleState = "Normal"
	// RuleStateTriggered is when the rule has it's conditions met
	RuleStateTriggered RuleState = "Triggered"
	// RuleStateActive is when the rule has it's actions being performed
	RuleStateActive RuleState = "Active"
	// RuleStateActiveActionTaken is when the rule has it's actions already taken
	// but still hasn't moved out of active status
	RuleStateActiveActionTaken RuleState = "ActiveActionsTaken"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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