Documentation ¶
Index ¶
- Variables
- func CacheID(v string) uint64
- func Clone(v interface{}) interface{}
- func GetVariableValue(ctx *Context, v Variable) interface{}
- func HashID(v string) uint64
- func IsArray(v interface{}) bool
- func IsScalar(v interface{}) bool
- func ToArray(value interface{}) []interface{}
- type AnyOperation
- type Assignment
- type AssignmentFactory
- type BaseAssignmentPrepareValue
- type BetweenOperation
- type Cache
- type Condition
- type ConditionGroup
- type Context
- func (c *Context) Cache() Cache
- func (c *Context) Data() interface{}
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Delete(key string)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetAll() map[string]interface{}
- func (c *Context) Set(key string, value interface{})
- func (c *Context) Trace() Trace
- func (c *Context) Value(key interface{}) interface{}
- type ContextOption
- type ContextOptionFunc
- type DeleteAssignment
- type Deleter
- type EqualAssignment
- type EqualOperation
- type Executor
- type ExecutorGroup
- type GROUP_LOGIC
- type GeOperation
- type GroupAssign
- type GtOperation
- type HasOperation
- type InOperation
- type LeOperation
- type LtOperation
- type MatchOperation
- type MergeAssignment
- type Merger
- type NoneOperation
- type NotEqualOperation
- type NotInOperation
- type NotMatchOperation
- type Operation
- type OperationFactory
- type ProbabilitySet
- type Setter
- type SimpleVariable
- type StaticValue
- type StdCondition
- type StdExecutor
- type StdLogger
- type Trace
- type ValueFunc
- type Valuer
- type Variable
- type VariableCreator
- type VariableCreatorFunc
- type VariableFactory
Constants ¶
This section is empty.
Variables ¶
var ( Cacheable = true Uncacheable = false )
Functions ¶
func GetVariableValue ¶
GetVariableValue get value of variable, also handlers variable cacheing, hooking logic
Types ¶
type AnyOperation ¶
type AnyOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (*AnyOperation) PrepareValue ¶
func (o *AnyOperation) PrepareValue(value interface{}) (interface{}, error)
type Assignment ¶
type AssignmentFactory ¶
type AssignmentFactory interface { Get(string) Assignment Register(Assignment, ...string) }
func GetAssignmentFactory ¶
func GetAssignmentFactory() AssignmentFactory
GetAssignmentFactory return AssignmentFactory for registering new Assigment
type BaseAssignmentPrepareValue ¶
type BaseAssignmentPrepareValue struct{}
func (*BaseAssignmentPrepareValue) PrepareValue ¶
func (self *BaseAssignmentPrepareValue) PrepareValue(value interface{}) (interface{}, error)
type BetweenOperation ¶
type BetweenOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (*BetweenOperation) PrepareValue ¶
func (o *BetweenOperation) PrepareValue(value interface{}) (interface{}, error)
type Cache ¶
type Cache interface { Load(key interface{}) (interface{}, bool) Store(key, value interface{}) Delete(key interface{}) }
type Condition ¶
Condition interface
func NewCondition ¶
func NewCondition(item []interface{}, groupLogic GROUP_LOGIC) (Condition, error)
type ConditionGroup ¶
type ConditionGroup struct {
// contains filtered or unexported fields
}
func NewConditionGroup ¶
func NewConditionGroup(logic GROUP_LOGIC) *ConditionGroup
func (*ConditionGroup) String ¶
func (c *ConditionGroup) String() string
func (*ConditionGroup) Success ¶
func (c *ConditionGroup) Success(ctx *Context) bool
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() *Context
func WithContext ¶
func WithContext(ctx context.Context, opts ...ContextOption) *Context
func WithData ¶
WithData return new *Context contains data. call every time the filter runs, to make data thread-safe
type ContextOption ¶
type ContextOption interface {
// contains filtered or unexported methods
}
type ContextOptionFunc ¶
type ContextOptionFunc func(*Context)
type DeleteAssignment ¶
type DeleteAssignment struct{}
func (*DeleteAssignment) PrepareValue ¶
func (self *DeleteAssignment) PrepareValue(value interface{}) (interface{}, error)
func (*DeleteAssignment) Run ¶
func (self *DeleteAssignment) Run(_ *Context, data interface{}, key string, value interface{})
type EqualAssignment ¶
type EqualAssignment struct{ BaseAssignmentPrepareValue }
func (*EqualAssignment) Run ¶
func (self *EqualAssignment) Run(_ *Context, data interface{}, key string, value interface{})
type EqualOperation ¶
type EqualOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (EqualOperation) PrepareValue ¶
func (o EqualOperation) PrepareValue(value interface{}) (interface{}, error)
type Executor ¶
type Executor interface {
Execute(*Context, interface{})
}
Executor
func NewExecutor ¶
type ExecutorGroup ¶
type ExecutorGroup struct {
// contains filtered or unexported fields
}
ExecutorGroup
func NewExecutorGroup ¶
func NewExecutorGroup() *ExecutorGroup
func (*ExecutorGroup) Execute ¶
func (e *ExecutorGroup) Execute(ctx *Context, data interface{})
type GROUP_LOGIC ¶
type GROUP_LOGIC int
ConditionGroup
const ( LOGIC_ALL GROUP_LOGIC = iota LOGIC_ANY LOGIC_NONE LOGIC_ANY_NOT )
type GeOperation ¶
type GeOperation struct { LtOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
func (GeOperation) PrepareValue ¶
func (o GeOperation) PrepareValue(value interface{}) (interface{}, error)
type GroupAssign ¶
type GroupAssign struct{}
func (*GroupAssign) PrepareValue ¶
func (a *GroupAssign) PrepareValue(value interface{}) (val interface{}, err error)
func (*GroupAssign) Run ¶
func (a *GroupAssign) Run(ctx *Context, data interface{}, key string, value interface{})
type GtOperation ¶
type GtOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (GtOperation) PrepareValue ¶
func (o GtOperation) PrepareValue(value interface{}) (interface{}, error)
type HasOperation ¶
type HasOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (*HasOperation) PrepareValue ¶
func (o *HasOperation) PrepareValue(value interface{}) (interface{}, error)
type InOperation ¶
type InOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (*InOperation) PrepareValue ¶
func (o *InOperation) PrepareValue(value interface{}) (interface{}, error)
type LeOperation ¶
type LeOperation struct { GtOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
func (LeOperation) PrepareValue ¶
func (o LeOperation) PrepareValue(value interface{}) (interface{}, error)
type LtOperation ¶
type LtOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (LtOperation) PrepareValue ¶
func (o LtOperation) PrepareValue(value interface{}) (interface{}, error)
type MatchOperation ¶
type MatchOperation struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------------
func (*MatchOperation) PrepareValue ¶
func (o *MatchOperation) PrepareValue(value interface{}) (interface{}, error)
type MergeAssignment ¶
type MergeAssignment struct{}
func (*MergeAssignment) PrepareValue ¶
func (self *MergeAssignment) PrepareValue(value interface{}) (interface{}, error)
func (*MergeAssignment) Run ¶
func (self *MergeAssignment) Run(_ *Context, data interface{}, key string, value interface{})
type NoneOperation ¶
type NoneOperation struct { AnyOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
type NotEqualOperation ¶
type NotEqualOperation struct { EqualOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
func (NotEqualOperation) PrepareValue ¶
func (o NotEqualOperation) PrepareValue(value interface{}) (interface{}, error)
type NotInOperation ¶
type NotInOperation struct { InOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
type NotMatchOperation ¶
type NotMatchOperation struct { MatchOperation // contains filtered or unexported fields }
----------------------------------------------------------------------------------
type OperationFactory ¶
func GetOperationFactory ¶
func GetOperationFactory() OperationFactory
type ProbabilitySet ¶
type ProbabilitySet struct { }
ProbabilitySet set value with specified probability. e.g. :
["key", "*=", [ [10, "value1"], [10, "value2"], [10, "value3"] ]] value1,value2,value3 has the same weight 10, each of them has a probability 10/(10+10+10) = 1/3 to been chosen.
func (*ProbabilitySet) PrepareValue ¶
func (a *ProbabilitySet) PrepareValue(value interface{}) (val interface{}, err error)
func (*ProbabilitySet) Run ¶
func (a *ProbabilitySet) Run(ctx *Context, data interface{}, key string, value interface{})
type SimpleVariable ¶
type SimpleVariable struct {
// contains filtered or unexported fields
}
SimpleVariable implements Variable interface
func (*SimpleVariable) Cacheable ¶
func (v *SimpleVariable) Cacheable() bool
func (*SimpleVariable) Name ¶
func (v *SimpleVariable) Name() string
func (*SimpleVariable) Value ¶
func (v *SimpleVariable) Value(ctx *Context) interface{}
type StaticValue ¶
type StaticValue struct {
Val interface{}
}
StaticValue static value implements Valuer interface
func (StaticValue) Value ¶
func (v StaticValue) Value(_ *Context) interface{}
type StdCondition ¶
type StdCondition struct {
// contains filtered or unexported fields
}
StdCondition
func (*StdCondition) String ¶
func (c *StdCondition) String() string
func (*StdCondition) Success ¶
func (c *StdCondition) Success(ctx *Context) bool
type StdExecutor ¶
type StdExecutor struct {
// contains filtered or unexported fields
}
StdExecutor
func (*StdExecutor) Execute ¶
func (e *StdExecutor) Execute(ctx *Context, data interface{})
type StdLogger ¶
type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) }
type Trace ¶
type VariableCreator ¶
type VariableCreatorFunc ¶
func SingletonVariableCreator ¶
func SingletonVariableCreator(instance Variable) VariableCreatorFunc
func (VariableCreatorFunc) Create ¶
func (f VariableCreatorFunc) Create(name string) Variable
type VariableFactory ¶
type VariableFactory interface { VariableCreator Register(VariableCreator, ...string) }
func GetVariableFactory ¶
func GetVariableFactory() VariableFactory
GetVariableFactory return VariableFactory