classifier

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module is a default set of components to enable flow classification

Note: this module provides just a Classifier datastructure, with no API endpoint. Example API endpoint to the classifier is pkg/envoy.

Types

type ActiveRuleset

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

ActiveRuleset represents one of currently active set of rules.

func (ActiveRuleset) Drop

func (rs ActiveRuleset) Drop()

Drop retracts all the rules belonging to a ruleset.

type ClassificationEngine

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

ClassificationEngine receives classification policies and provides Classify method.

func NewClassificationEngine

func NewClassificationEngine(registry status.Registry) *ClassificationEngine

NewClassificationEngine creates a new Flow Classifier.

func ProvideClassificationEngine

func ProvideClassificationEngine(in ClassificationEngineIn) (iface.ClassificationEngine, *ClassificationEngine)

ProvideClassificationEngine provides a classifier that loads the rules from config file.

func (*ClassificationEngine) ActiveRules

func (c *ClassificationEngine) ActiveRules() []compiler.ReportedRule

ActiveRules returns a slice of uncompiled Rules which are currently active.

func (*ClassificationEngine) AddPreview added in v0.19.0

func (c *ClassificationEngine) AddPreview(preview iface.HTTPRequestPreview)

AddPreview adds a preview to the active previews.

func (*ClassificationEngine) AddRules

func (c *ClassificationEngine) AddRules(
	ctx context.Context,
	name string,
	classifierWrapper *policysyncv1.ClassifierWrapper,
) (ActiveRuleset, error)

AddRules compiles a ruleset and adds it to the active rules

The name will be used for reporting

To retract the rules, call Classifier.Drop.

func (*ClassificationEngine) Classify

func (c *ClassificationEngine) Classify(
	ctx context.Context,
	svcs []string,
	ctrlPt string,
	labelsForMatching map[string]string,
	input map[string]interface{},
) ([]*flowcontrolv1.ClassifierInfo, flowlabel.FlowLabels)

Classify takes rego input, performs classification, and returns a map of flow labels. LabelsForMatching are additional labels to use for selector matching.

func (*ClassificationEngine) DropPreview added in v0.19.0

func (c *ClassificationEngine) DropPreview(preview iface.HTTPRequestPreview)

DropPreview removes a preview from the active previews.

func (*ClassificationEngine) GetClassifier

func (c *ClassificationEngine) GetClassifier(classifierID iface.ClassifierID) iface.Classifier

GetClassifier Lookup function for getting classifier.

func (*ClassificationEngine) RegisterClassifier

func (c *ClassificationEngine) RegisterClassifier(classifier iface.Classifier) error

RegisterClassifier adds classifier to map.

func (*ClassificationEngine) UnregisterClassifier

func (c *ClassificationEngine) UnregisterClassifier(classifier iface.Classifier) error

UnregisterClassifier removes classifier from map.

type ClassificationEngineIn

type ClassificationEngineIn struct {
	fx.In
	Watcher      notifiers.Watcher `name:"classifier"`
	Lifecycle    fx.Lifecycle
	Registry     status.Registry
	PromRegistry *prometheus.Registry
}

ClassificationEngineIn holds parameters for ProvideClassificationEngine.

type Classifier

type Classifier struct {
	iface.Classifier
	// contains filtered or unexported fields
}

Classifier implements iface.Classifier interface.

func (*Classifier) GetClassifierID

func (c *Classifier) GetClassifierID() iface.ClassifierID

GetClassifierID returns ClassifierID object that should uniquely identify classifier.

func (*Classifier) GetFlowSelector added in v0.15.0

func (c *Classifier) GetFlowSelector() *policylangv1.FlowSelector

GetFlowSelector returns the flow selector.

func (*Classifier) GetRequestCounter

func (c *Classifier) GetRequestCounter() prometheus.Counter

GetRequestCounter returns the counter for the classifier.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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