rtengine

package
v0.0.64 Latest Latest
Warning

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

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

Documentation

Overview

Package rtengine contains the rule type engine

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRulesFromProfileOfType

func GetRulesFromProfileOfType(p *minderv1.Profile, rt *minderv1.RuleType) ([]*minderv1.Profile_Rule, error)

GetRulesFromProfileOfType returns the rules from the profile of the given type

Types

type Cache added in v0.0.56

type Cache interface {
	// GetRuleEngine retrieves the rule type engine instance for the specified rule type
	GetRuleEngine(ctx context.Context, ruleTypeID uuid.UUID) (*RuleTypeEngine, error)
}

Cache contains a set of RuleTypeEngine instances

func NewRuleEngineCache added in v0.0.56

func NewRuleEngineCache(
	ctx context.Context,
	store db.Querier,
	entityType db.Entities,
	projectID uuid.UUID,
	provider provinfv1.Provider,
	ingestCache ingestcache.Cache,
) (Cache, error)

NewRuleEngineCache creates the rule engine cache It attempts to pre-populate the cache with all the relevant rule types for this entity and project hierarchy.

type RuleMeta

type RuleMeta struct {
	// Name is the name of the rule
	Name string
	// Organization is the ID of the organization that this rule is for
	Organization *string
	// Project is the ID of the project that this rule is for
	Project *string
}

RuleMeta is the metadata for a rule TODO: We probably should care about a version

func (*RuleMeta) String

func (r *RuleMeta) String() string

String returns a string representation of the rule meta

type RuleTypeEngine

type RuleTypeEngine struct {
	Meta RuleMeta
	// contains filtered or unexported fields
}

RuleTypeEngine is the engine for a rule type. It builds the multiple sections of the rule type and instantiates the needed drivers for them.

func NewRuleTypeEngine

func NewRuleTypeEngine(
	ctx context.Context,
	ruletype *minderv1.RuleType,
	provider provinfv1.Provider,
) (*RuleTypeEngine, error)

NewRuleTypeEngine creates a new rule type engine

func (*RuleTypeEngine) Eval

func (r *RuleTypeEngine) Eval(
	ctx context.Context,
	inf *entities.EntityInfoWrapper,
	params engif.EvalParamsReadWriter,
) (finalErr error)

Eval runs the rule type engine against the given entity

func (*RuleTypeEngine) GetID

func (r *RuleTypeEngine) GetID() string

GetID returns the ID of the rule type. The ID is meant to be a serializable unique identifier for the rule type.

func (*RuleTypeEngine) GetRuleInstanceValidator

func (r *RuleTypeEngine) GetRuleInstanceValidator() *profiles.RuleValidator

GetRuleInstanceValidator returns the rule instance validator for this rule type. By instance we mean a rule that has been instantiated in a profile from a given rule type.

func (*RuleTypeEngine) GetRuleType added in v0.0.56

func (r *RuleTypeEngine) GetRuleType() *minderv1.RuleType

GetRuleType returns the rule type PB structure.

func (*RuleTypeEngine) WithIngesterCache

func (r *RuleTypeEngine) WithIngesterCache(ingestCache ingestcache.Cache) *RuleTypeEngine

WithIngesterCache sets the ingester cache for the rule type engine

Jump to

Keyboard shortcuts

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