rules

package
v0.0.0-...-08fea6f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionFunc

type ActionFunc func(ctx context.Context) (context.Context, error)

ActionFunc defines a function type for actions with support for dependencies and context

type Option

type Option func(*execOptions)

Option defines a functional option for configuring rule execution

func WithAtomic

func WithAtomic(atomic bool) Option

WithAtomic sets atomic execution: the rule execution stops on the first error

func WithReturnErrors

func WithReturnErrors(returnErrors bool) Option

WithReturnErrors enables error return via channel

type Rule

type Rule struct {
	ID        uuid.UUID
	Name      string
	Condition string
	Action    ActionFunc
	Next      *Rule
}

Rule defines the structure for a rule with a condition, action, and an optional next rule

type RuleEngine

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

RuleEngine manages the execution of rules

func NewRuleEngine

func NewRuleEngine(storage Storage, decl ...*exprpb.Decl) (*RuleEngine, error)

NewRuleEngine creates a new instance of RuleEngine

func (*RuleEngine) ExecuteRules

func (re *RuleEngine) ExecuteRules(ctx context.Context, inputData map[string]interface{}, opts ...Option) <-chan error

ExecuteRules executes the rules with given input data, context, and options

type Storage

type Storage interface {
	LoadRules() ([]Rule, error)
}

Jump to

Keyboard shortcuts

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