rule

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckFunctionsEnvOptions = []cel.EnvOption{

	absDoubleFunc,
	absIntFunc,

	nowFunc,

	makeSequenceInt(nil),
	makeSequenceUint(nil),
	makeSequenceFloat64(nil),
	makeSequenceString(nil),

	makeCompleteInt(nil),
	makeCompleteUint(nil),
	makeCompleteFloat64(nil),
}

CheckFunctionsEnvOptions contains all the custom functions used when defining check rules. Stateful functions added here are dummy functions that are overloaded on-demand with a correctly initialized state when a rule is created.

View Source
var StreamFunctionsEnvOptions = []cel.EnvOption{

	absDoubleFunc,
	absIntFunc,

	nowFunc,
}

StreamFunctionsEnvOptions contains all the custom functions used when defining stream rules.

Functions

func ParseStatefulFunctions added in v0.3.0

func ParseStatefulFunctions(statefulFunctions []StatefulFunction, expression *expr.Expr) error

Types

type Builder

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

func NewBuilder

func NewBuilder(schema sample.Schema, supportedFunctions SupportedFunctions) (*Builder, error)

func (*Builder) Build

func (rb *Builder) Build(rule string) (*Rule, error)

type CompleteState added in v0.3.0

type CompleteState[T Number] struct {
	AllComplete bool
	// contains filtered or unexported fields
}

func NewCompleteState added in v0.3.0

func NewCompleteState[T Number](step T) *CompleteState[T]

func (*CompleteState[T]) Add added in v0.3.0

func (ss *CompleteState[T]) Add(value T) bool

type CompleteStateProvider added in v0.3.0

type CompleteStateProvider interface {
	CompleteAddInt64(int64) bool
	CompleteAddUint64(uint64) bool
	CompleteAddFloat64(float64) bool
}

complete (stateful)

type CompleteStatefulFunction added in v0.3.0

type CompleteStatefulFunction struct {
	Step float64
	// contains filtered or unexported fields
}

func (*CompleteStatefulFunction) Enabled added in v0.3.0

func (csf *CompleteStatefulFunction) Enabled() bool

func (*CompleteStatefulFunction) GetCelEnvs added in v0.3.0

func (csf *CompleteStatefulFunction) GetCelEnvs(stateProvider *StateProvider) []cel.EnvOption

func (*CompleteStatefulFunction) GetName added in v0.3.0

func (csf *CompleteStatefulFunction) GetName() string

func (*CompleteStatefulFunction) ParseCallExpression added in v0.3.0

func (csf *CompleteStatefulFunction) ParseCallExpression(callExpression *expr.Expr_Call) error

type Number added in v0.3.0

type Number interface {
	constraints.Float | constraints.Integer
}

CompleteState

type OrderType added in v0.3.0

type OrderType int8
const (
	OrderTypeUnknown OrderType = iota
	OrderTypeNone
	OrderTypeAsc
	OrderTypeDesc
)

type Rule

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

func New

func New(schema sample.Schema, prg cel.Program, stateProvider *StateProvider) *Rule

func (*Rule) Eval

func (r *Rule) Eval(ctx context.Context, sampleData *data.Data) (bool, error)

func (*Rule) StateProvider added in v0.3.0

func (r *Rule) StateProvider() *StateProvider

type SequenceState added in v0.3.0

type SequenceState[T constraints.Ordered] struct {
	Order OrderType
	// contains filtered or unexported fields
}

SequenceState

func NewSequenceState added in v0.3.0

func NewSequenceState[T constraints.Ordered](orderType OrderType) *SequenceState[T]

func (*SequenceState[T]) Add added in v0.3.0

func (ss *SequenceState[T]) Add(value T) bool

type SequenceStateProvider added in v0.3.0

type SequenceStateProvider interface {
	SequenceAddInt64(int64) bool
	SequenceAddUint64(uint64) bool
	SequenceAddFloat64(float64) bool
	SequenceAddString(string) bool
}

sequence (stateful)

type SequenceStatefulFunction added in v0.3.0

type SequenceStatefulFunction struct {
	Order OrderType
	// contains filtered or unexported fields
}

func (*SequenceStatefulFunction) Enabled added in v0.3.0

func (ssf *SequenceStatefulFunction) Enabled() bool

func (*SequenceStatefulFunction) GetCelEnvs added in v0.3.0

func (ssf *SequenceStatefulFunction) GetCelEnvs(stateProvider *StateProvider) []cel.EnvOption

func (*SequenceStatefulFunction) GetName added in v0.3.0

func (ssf *SequenceStatefulFunction) GetName() string

func (*SequenceStatefulFunction) ParseCallExpression added in v0.3.0

func (ssf *SequenceStatefulFunction) ParseCallExpression(callExpression *expr.Expr_Call) error

type StateProvider added in v0.3.0

type StateProvider struct {
	// Sequence state
	SequenceEnabled bool

	// Complete state
	CompleteEnabled bool
	// contains filtered or unexported fields
}

StateProvider

func NewStateProvider added in v0.3.0

func NewStateProvider() *StateProvider

func (*StateProvider) CompleteAddFloat64 added in v0.3.0

func (sp *StateProvider) CompleteAddFloat64(v float64) bool

func (*StateProvider) CompleteAddInt64 added in v0.3.0

func (sp *StateProvider) CompleteAddInt64(v int64) bool

func (*StateProvider) CompleteAddUint64 added in v0.3.0

func (sp *StateProvider) CompleteAddUint64(v uint64) bool

func (*StateProvider) SequenceAddFloat64 added in v0.3.0

func (sp *StateProvider) SequenceAddFloat64(v float64) bool

func (*StateProvider) SequenceAddInt64 added in v0.3.0

func (sp *StateProvider) SequenceAddInt64(v int64) bool

func (*StateProvider) SequenceAddString added in v0.3.0

func (sp *StateProvider) SequenceAddString(v string) bool

func (*StateProvider) SequenceAddUint64 added in v0.3.0

func (sp *StateProvider) SequenceAddUint64(v uint64) bool

func (*StateProvider) WithCompleteState added in v0.3.0

func (sp *StateProvider) WithCompleteState(step float64) *StateProvider

func (*StateProvider) WithSequenceState added in v0.3.0

func (sp *StateProvider) WithSequenceState(order OrderType) *StateProvider

type StatefulFunction added in v0.3.0

type StatefulFunction interface {
	GetName() string
	Enabled() bool
	ParseCallExpression(callExpression *expr.Expr_Call) error
	GetCelEnvs(stateProvider *StateProvider) []cel.EnvOption
}

type SupportedFunctions added in v0.3.0

type SupportedFunctions int
const (
	StreamFunctions SupportedFunctions = iota
	CheckFunctions
)

Jump to

Keyboard shortcuts

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