typedef

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionAim

type ActionAim interface {
	ActionName() string
	Parameter() interface{}
	ParamAsMap() (paramMap map[string]interface{})
	ParamAsList() (paramList []interface{})
}

ActionAim is the interface that defines the aim of action.

type Aim

type Aim interface {
	AsExpr() interface{}
	AsActionList() []ActionAim
	AsAction() ActionAim
}

Aim is the interface that supports type convert.

type Comparable

type Comparable interface {
	Compare(other Comparable) int
}

Comparable is the interface that can compare with other Comparable instance.

type ConcurrentPool added in v1.0.5

type ConcurrentPool interface {
	Submit(t Task, p interface{})
	SubmitWait(t Task, p interface{})
}

type DataCtx

type DataCtx interface {
	SharedVisitCache

	Context() context.Context

	FetcherFetcher() FeatureFetcher
	PrefetchFeatures(feats []FeatureParam)

	GetFactMeta() MetaType
	GetVarValue(varPath []string) (interface{}, error)
	GetFeatureValue(featParam FeatureParam, fieldPaths ...string) (interface{}, error)

	GetAllFeatures() []Feature

	SetExtra(key interface{}, value interface{})
	GetExtra(key interface{}) (value interface{})
}

DataCtx is the data context during the rule visitation.

type ErrMsg

type ErrMsg string

func (ErrMsg) HashCode

func (e ErrMsg) HashCode() string

type Feature

type Feature interface {
	Hashable

	BuiltinParam() MetaType
	FeatureMeta() MetaType
}

Feature holds the builtin parameters and metas fetched from user.

type FeatureFetchObserver

type FeatureFetchObserver interface {
	Hashable

	OnFeatureFetchStart(ctx context.Context, feat FeatureParam)
	OnFeatureFetchEnd(ctx context.Context, featureHash string, featureValue MetaType, err error)
}

FeatureFetchObserver can listen to feature fetch events.

type FeatureFetcher

type FeatureFetcher interface {
	ObservableFeatureFetcher

	// FetchFeature fetch one feature, return data type is map[string]interface{}
	FetchFeature(ctx context.Context, feat FeatureParam, dc DataCtx) (MetaType, error)
}

FeatureFetcher supports fetch of feature, need user implementation.

type FeatureParam

type FeatureParam interface {
	Hashable

	// FeatureName is the name of one feature which is the first word separated from feature path in the Arishem rule expression.
	FeatureName() string
	// BuiltinParam is the parameter which is builtin rule expression.
	BuiltinParam() MetaType
}

FeatureParam is the parameter pass to FeatureFetcher to fetch a feature, which uniquely identifies a feature snapshot in a DataCtx.

type FeaturePreParser

type FeaturePreParser interface {
	ParseObserver

	Data() []FeatureParam
	Error() error
}

FeaturePreParser implement the ParseObserver and parse feature info in Arishem rule.

type Hashable

type Hashable interface {
	HashCode() string
}

Hashable is the interface that limit an object to unique itself.

type Identifiable

type Identifiable interface {
	Identifier() string
}

Identifiable is the interface that can be identified.

type JudgeNode

type JudgeNode interface {
	Passed() bool
	Left() interface{}
	LeftExpr() string
	Right() interface{}
	RightExpr() string
	Operator() string
	Error() error
}

JudgeNode is the node of every single condition.

type MetaType

type MetaType map[string]interface{}

type ObservableFeatureFetcher

type ObservableFeatureFetcher interface {
	AddFetchObserver(v ...FeatureFetchObserver)
	GetFetchObservers() []FeatureFetchObserver
	ClearFetchObservers()
}

ObservableFeatureFetcher supports feature fetch events callback behaviour.

type ObservableVisitor

type ObservableVisitor interface {
	AddVisitObserver(v ...VisitObserver)
	GetVisitObservers() []VisitObserver
	ClearVisitObservers()
}

ObservableVisitor supports rule events callback behaviour.

type ParseObserver

type ParseObserver interface {
	VisitTerminal(node antlr.TerminalNode, tokenErrMsgs, parseErrMsgs []string)
	VisitErrorNode(node antlr.ErrorNode, tokenErrMsgs, parseErrMsgs []string)
	EnterEveryRule(ctx antlr.ParserRuleContext, tokenErrMsgs, parseErrMsgs []string)
	ExitEveryRule(ctx antlr.ParserRuleContext, tokenErrMsgs, parseErrMsgs []string)
}

ParseObserver is the observer that can listen to rule parse events with token and parse error messages.

type Pool

type Pool interface {
	Ask() Poolable
	Giveback(p Poolable)
}

Pool is the object pool interface.

type Poolable

type Poolable interface {
	Reset()
}

Poolable is the interface that can be recycled in an object pool.

type RuleVisitor

type RuleVisitor interface {
	ObservableVisitor

	// VisitCondition will visit condition context and return condition whether passed.
	VisitCondition(cdtCtx antlr.ParseTree, dCtx DataCtx, vt VisitTarget) (pass bool)
	// VisitAim will visit aim context and return aim value.
	VisitAim(aimCtx antlr.ParseTree, dCtx DataCtx, vt VisitTarget) (aim Aim)
}

RuleVisitor is the interface that defines rule visit behaviour.

type Set

type Set interface {
	Add(h Hashable)
	Remove(h Hashable)
	Contains(h Hashable) bool
	AsList() []Hashable
}

type SharedVisitCache

type SharedVisitCache interface {
	// Get will get cached node visit result by its alternative number, Set and Get must concurrent safe.
	Get(key interface{}) (val interface{}, ok bool)
	// Set will set a visit result by its alternative number.
	Set(key interface{}, val interface{})
}

SharedVisitCache is the interface that can pass data among multi visitors.

type Task added in v1.0.5

type Task func(param interface{})

Task execute mission with the parameter

type VisitObserver

type VisitObserver interface {
	Hashable

	// OnJudgeNodeVisitEnd passes the condition node
	OnJudgeNodeVisitEnd(ctx context.Context, info JudgeNode, vt VisitTarget)
	OnVisitError(ctx context.Context, node, errMsg string, vt VisitTarget)
}

VisitObserver is the observer that can listen to rule visit events.

type VisitTarget

type VisitTarget Identifiable

VisitTarget can be identified.

Jump to

Keyboard shortcuts

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