Documentation ¶
Index ¶
- type ActionAim
- type Aim
- type Comparable
- type ConcurrentPool
- type DataCtx
- type ErrMsg
- type Feature
- type FeatureFetchObserver
- type FeatureFetcher
- type FeatureParam
- type FeaturePreParser
- type Hashable
- type Identifiable
- type JudgeNode
- type MetaType
- type ObservableFeatureFetcher
- type ObservableVisitor
- type ParseObserver
- type Pool
- type Poolable
- type RuleVisitor
- type Set
- type SharedVisitCache
- type Task
- type VisitObserver
- type VisitTarget
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 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 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 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 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 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) SetConditionFinder(cf func(condName string) (antlr.ParseTree, error)) }
RuleVisitor is the interface that defines rule visit behaviour.
type SharedVisitCache ¶
type SharedVisitCache interface { bool) Set(key interface{}, val interface{}) }Get(key interface{}) (val interface{}, ok
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.